-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support async pipe #3
Labels
enhancement
New feature or request
Comments
@4513ECHO Could you try |
It works fine. Thanks! |
📝 This was required to combine the following two import { pipe } from "jsr:@core/pipe";
import { pipe as pipeAsync } from "jsr:@core/pipe/async";
import { toAsyncIterable } from "jsr:@core/iterutil/async/to-async-iterable";
import { map } from "jsr:@core/iterutil/pipe/async/map";
// We must resolve the promise before we can use the value
// in the next pipe function. So that we cannot combine
// the following two pipes into one.
const fst = await pipe(
toAsyncIterable([1, 2, 3]),
map((x) => x * 2),
(v) => Array.fromAsync(v),
);
const snd = pipe(
fst,
(v) => v.join(""),
(v) => v.repeat(2),
);
console.log(snd);
// If we use `pipe/async` instead, we can combine the two pipes
const trd = await pipeAsync(
toAsyncIterable([1, 2, 3]),
map((x) => x * 2),
(v) => Array.fromAsync(v),
(v) => v.join(""),
(v) => v.repeat(2),
);
console.log(trd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently piping async function to sync function is impossible.
We need
jsr:@core/pipe/async
or something to support it.The text was updated successfully, but these errors were encountered: