@fink/std-lib
Version:
fink standard lib
62 lines (47 loc) • 950 B
JavaScript
const {
ˆnew
} = require("@fink/js-interop/reflect.js");
const {
Promise,
globals
} = require("@fink/js-interop/globals.js");
const {
iter,
next
} = require("./iter.js");
const {
is_fn
} = require("./fn.js");
const parallel = async tasks => await Promise.all([...tasks]);
exports.parallel = parallel;
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);
}
}
}
};
exports.sequential = sequential;
const sleep = ms => ˆnew(Promise, resolve => globals.setTimeout(resolve, ms));
exports.sleep = sleep;
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;
}
};
exports.is_async = is_async;