Skip to content

Commit 2ea9e18

Browse files
authored
Merge pull request #4 from jsr-core/add-async-pipe
feat(async): add async `pipe` function
2 parents f6f3a75 + aa0829f commit 2ea9e18

File tree

5 files changed

+666
-5
lines changed

5 files changed

+666
-5
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ const result = pipe(
3232
console.log(result); // "4"
3333
```
3434

35+
Or use `async` module to pipe a value through a series of asynchronous operator
36+
functions.
37+
38+
```ts
39+
import { pipe } from "@core/pipe/async";
40+
41+
const result = pipe(
42+
1,
43+
(v) => Promise.resolve(v + 1), // inferred as (v: number) => number | Promise<number>
44+
(v) => Promise.resolve(v * 2), // inferred as (v: number) => number | Promise<number>
45+
(v) => Promise.resolve(v.toString()), // inferred as (v: number) => string | Promise<string>
46+
);
47+
console.log(result); // "4"
48+
```
49+
3550
## License
3651

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

0 commit comments

Comments
 (0)