depend-async-js
A small library that define multiple promises to be resolved asynchronously but without to resolve everything at once with the ability to grab the data from the previous promise result.
Commands
"test": "vitest",
"test:ui": "vitest --ui",
"coverage": "vitest run --coverage",
"build": "yarn vite build --debug"
const resolve: Func<any> = (num: number, timeout?: number) => async (prev: any) => new Promise((resolve) => {
timeout ?
setTimeout(() => {
resolve(num);
}, timeout) :
resolve(num);
});
const __test__ = await ResolvePromises([
resolve(10), resolve(30), resolve(20),
resolve(10), resolve(30), resolve(20),
[
resolve(10), resolve(30), resolve(20),
resolve(10), resolve(30), resolve(20),
resolve(10), resolve(30), resolve(20),
(prev: any) => resolve(prev + 2)(prev + 2),
(prev: any) => resolve(prev - 2)(prev - 2),
]
]);
expect(__test__).toEqual([
10, 30, 20,
10, 30, 20,
10, 30, 20,
10, 30, 20,
10, 30, 20, 22, 20
]);
Package size
ES:
normal: 0.26kb
gzip: 0.20kb
CJS:
normal: 0.29kb
gzip: 0.24kb
UMD:
normal: 0.49kb
gzip: 0.34kb