@aegenet/belt-promise
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

npm version

@aegenet/belt-promise

Promise toolkit

💾 Installation

yarn add @aegenet/belt-promise@^1.4.0
# or
npm i @aegenet/belt-promise@^1.4.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]

Readme

Keywords

Package Sidebar

Install

npm i @aegenet/belt-promise

Weekly Downloads

2

Version

1.5.0

License

MIT

Unpacked Size

7 kB

Total Files

10

Last publish

Collaborators

  • agenet