Skip to content

Commit

Permalink
feat(async): add async pipe function
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Aug 22, 2024
1 parent c90f6d7 commit f840db3
Show file tree
Hide file tree
Showing 4 changed files with 662 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ const result = pipe(
console.log(result); // "4"
```

Or use `async` module to pipe a value through a series of asynchronous operator
functions.

```ts
import { pipe } from "@core/pipe/async";

const result = pipe(
1,
(v) => Promise.resolve(v + 1), // inferred as (v: number) => number | Promise<number>
(v) => Promise.resolve(v * 2), // inferred as (v: number) => number | Promise<number>
(v) => Promise.resolve(v.toString()), // inferred as (v: number) => string | Promise<string>
);
console.log(result); // "4"
```

## License

The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
Expand Down
Loading

0 comments on commit f840db3

Please sign in to comment.