@aegenet/belt-promise
v2.3.0
Published
Promise toolkit
Downloads
93
Readme
@aegenet/belt-promise
Promise toolkit
💾 Installation
yarn add @aegenet/belt-promise@^2.0.0
# or
npm i @aegenet/belt-promise@^2.0.0
📝 Usage
isPromise
import { isPromise } from '@aegenet/belt-promise';
isPromise(Promise.resolve(true)); // true
isPromise(5); // false
isPromise(null); // false
isPromise(undefined); // false
isPromise(() => true); // false
isPromise({ id: 5 }); // false
delay
import { delay } from '@aegenet/belt-promise';
await delay(500); // ms
runSequentially
import { runSequentially } from '@aegenet/belt-promise';
await runSequentially(
() => {
/** Step 1 */;
},
() => {
/** Step 2 */;
}
);
collectSequentially
import { collectSequentially } from '@aegenet/belt-promise';
const results = await collectSequentially(
() => {
/** Step 1 */;
return 5;
},
() => {
/** Step 2 */;
return 3;
}
);
// results: [5, 3]