@fink/std-lib
Version:
fink standard lib
37 lines (33 loc) • 821 B
JavaScript
import { ˆnew } from "@fink/js-interop/reflect.js";
import { Promise, globals } from "@fink/js-interop/globals.js";
import { iter, next } from "./iter.js";
import { is_fn } from "./fn.js";
export const parallel = async tasks => await Promise.all([...tasks]);
export const sequential = async tasks => {
const it = iter(tasks);
const [task, rest] = next(it);
{
const ˆvalue_1 = task;
if (ˆvalue_1 != null) {
{
await task;
return await sequential(rest);
}
}
}
};
export const sleep = ms => ˆnew(Promise, resolve => globals.setTimeout(resolve, ms));
export const is_async = value => {
const ˆvalue_3 = value;
if (ˆvalue_3 != null) {
const {
then: ˆp_5
} = ˆvalue_3;
if (is_fn(ˆp_5)) {
return true;
}
}
{
return false;
}
};