Skip to content

Commit 3b76894

Browse files
committed
Ran prettier on typecheck tessts
1 parent d0ea4c5 commit 3b76894

File tree

4 files changed

+1186
-1535
lines changed

4 files changed

+1186
-1535
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### Minor Changes
66

77
- [#467](https://github.com/supermacro/neverthrow/pull/467) [`4b9d2fd`](https://github.com/supermacro/neverthrow/commit/4b9d2fdaf03223945068509f948b57194732aa03) Thanks [@untidy-hair
8-
](https://github.com/untidy-hair)! - feat: add `andTee` and `andThrough` to handle side-effect
8+
](https://github.com/untidy-hair)! - feat: add `andTee` and `andThrough` to handle side-effect
99

1010
### Patch Changes
1111

README.md

+23-20
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ Note that in the above example if `parseHeaders` returns an `Err` then `.map` an
539539
#### `Result.andTee` (method)
540540

541541
Takes a `Result<T, E>` and lets the original `Result<T, E>` pass through regardless the result of the passed-in function.
542-
This is a handy way to handle side effects whose failure or success should not affect your main logics such as logging.
542+
This is a handy way to handle side effects whose failure or success should not affect your main logics such as logging.
543543

544544
**Signature:**
545545

@@ -560,7 +560,7 @@ import { insertUser } from 'imaginary-database'
560560

561561
// ^ assume parseUserInput, logUser and insertUser have the following signatures:
562562
// parseUserInput(input: RequestData): Result<User, ParseError>
563-
// logUser(user: User): Result<void, LogError>
563+
// logUser(user: User): Result<void, LogError>
564564
// insertUser(user: User): ResultAsync<void, InsertError>
565565
// Note logUser returns void upon success but insertUser takes User type.
566566

@@ -579,7 +579,7 @@ resAsync.then((res: Result<void, ParseError | InsertError>) => {e
579579
}))
580580
```
581581

582-
[⬆️ Back to top](#toc)
582+
[⬆️ Back to top](#toc)
583583

584584
---
585585

@@ -610,7 +610,7 @@ import { insertUser } from 'imaginary-database'
610610
// parseUserInput(input: RequestData): Result<User, ParseError>
611611
// validateUser(user: User): Result<void, ValidateError>
612612
// insertUser(user: User): ResultAsync<void, InsertError>
613-
// Note validateUser returns void upon success but insertUser takes User type.
613+
// Note validateUser returns void upon success but insertUser takes User type.
614614

615615
const resAsync = parseUserInput(userInput)
616616
.andThrough(validateUser)
@@ -625,14 +625,14 @@ resAsync.then((res: Result<void, ParseErro | ValidateError | InsertError>) => {e
625625
}
626626
}))
627627
```
628-
629-
[⬆️ Back to top](#toc)
628+
629+
[⬆️ Back to top](#toc)
630630

631631
---
632632

633633
#### `Result.asyncAndThrough` (method)
634634

635-
Similar to `andThrough` except you must return a ResultAsync.
635+
Similar to `andThrough` except you must return a ResultAsync.
636636

637637
You can then chain the result of `asyncAndThrough` using the `ResultAsync` apis (like `map`, `mapErr`, `andThen`, etc.)
638638

@@ -647,7 +647,7 @@ import { sendNotification } from 'imaginary-service'
647647
// parseUserInput(input: RequestData): Result<User, ParseError>
648648
// insertUser(user: User): ResultAsync<void, InsertError>
649649
// sendNotification(user: User): ResultAsync<void, NotificationError>
650-
// Note insertUser returns void upon success but sendNotification takes User type.
650+
// Note insertUser returns void upon success but sendNotification takes User type.
651651

652652
const resAsync = parseUserInput(userInput)
653653
.asyncAndThrough(insertUser)
@@ -662,10 +662,11 @@ resAsync.then((res: Result<void, ParseError | InsertError | NotificationError>)
662662
}
663663
}))
664664
```
665-
666-
[⬆️ Back to top](#toc)
665+
666+
[⬆️ Back to top](#toc)
667667

668668
---
669+
669670
#### `Result.fromThrowable` (static class method)
670671

671672
> Although Result is not an actual JS class, the way that `fromThrowable` has been implemented requires that you call `fromThrowable` as though it were a static method on `Result`. See examples below.
@@ -1205,11 +1206,12 @@ const resultMessage = await validateUser(user)
12051206
[⬆️ Back to top](#toc)
12061207

12071208
---
1209+
12081210
#### `ResultAsync.andTee` (method)
12091211

1210-
Takes a `ResultAsync<T, E>` and lets the original `ResultAsync<T, E>` pass through regardless
1212+
Takes a `ResultAsync<T, E>` and lets the original `ResultAsync<T, E>` pass through regardless
12111213
the result of the passed-in function.
1212-
This is a handy way to handle side effects whose failure or success should not affect your main logics such as logging.
1214+
This is a handy way to handle side effects whose failure or success should not affect your main logics such as logging.
12131215

12141216
**Signature:**
12151217

@@ -1232,28 +1234,28 @@ import { sendNotification } from 'imaginary-service'
12321234
// insertUser(user: User): ResultAsync<User, InsertError>
12331235
// logUser(user: User): Result<void, LogError>
12341236
// sendNotification(user: User): ResultAsync<void, NotificationError>
1235-
// Note logUser returns void on success but sendNotification takes User type.
1237+
// Note logUser returns void on success but sendNotification takes User type.
12361238

12371239
const resAsync = insertUser(user)
12381240
.andTee(logUser)
12391241
.andThen(sendNotification)
12401242

1241-
// Note there is no LogError in the types below
1243+
// Note there is no LogError in the types below
12421244
resAsync.then((res: Result<void, InsertError | NotificationError>) => {e
12431245
if(res.isErr()){
12441246
console.log("Oops, at least one step failed", res.error)
12451247
}
12461248
else{
12471249
console.log("User has been inserted and notified successfully.")
12481250
}
1249-
}))
1251+
}))
12501252
```
12511253

1252-
[⬆️ Back to top](#toc)
1254+
[⬆️ Back to top](#toc)
12531255

12541256
---
1255-
#### `ResultAsync.andThrough` (method)
12561257

1258+
#### `ResultAsync.andThrough` (method)
12571259

12581260
Similar to `andTee` except for:
12591261

@@ -1281,7 +1283,7 @@ import { sendNotification } from 'imaginary-service'
12811283
// buildUser(userRaw: UserRaw): ResultAsync<User, BuildError>
12821284
// insertUser(user: User): ResultAsync<void, InsertError>
12831285
// sendNotification(user: User): ResultAsync<void, NotificationError>
1284-
// Note insertUser returns void upon success but sendNotification takes User type.
1286+
// Note insertUser returns void upon success but sendNotification takes User type.
12851287

12861288
const resAsync = buildUser(userRaw)
12871289
.andThrough(insertUser)
@@ -1294,12 +1296,13 @@ resAsync.then((res: Result<void, BuildError | InsertError | NotificationError>)
12941296
else{
12951297
console.log("User data has been built, inserted and notified successfully.")
12961298
}
1297-
}))
1299+
}))
12981300
```
12991301

1300-
[⬆️ Back to top](#toc)
1302+
[⬆️ Back to top](#toc)
13011303

13021304
---
1305+
13031306
#### `ResultAsync.combine` (static class method)
13041307

13051308
Combine lists of `ResultAsync`s.

package-lock.json

+2-86
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)