Skip to content

Commit

Permalink
Merge pull request #4 from jsr-core/add-async-pipe
Browse files Browse the repository at this point in the history
feat(async): add async `pipe` function
  • Loading branch information
lambdalisue authored Aug 22, 2024
2 parents f6f3a75 + aa0829f commit 2ea9e18
Show file tree
Hide file tree
Showing 5 changed files with 666 additions and 5 deletions.
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 2ea9e18

Please sign in to comment.