promise-utils-fl
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

promise-utils-fl

Utilities for promises. Module includes defer, wait, forEach and callback to promise converter.

Example

import {PromiseUtils} from "promise-utils-fl";

// Wait 2s
PromiseUtils.wait(2000);

// Perform promises one by one
PromiseUtils.forEach(["a", "b", "c"], (entry, index) => doWork(entry));

// Create deferred promise
let defer = PromiseUtils.defer<string>();
defer.promise; // returns promise
...
defer.resolve("foo"); // resolve promise
defer.reject("error"); // or reject it

// Convert callback to promise
PromiseUtils.cb2p<Buffer>(x => fs.readFile(filePath, x));

// Convert callback (without error) to promise
PromiseUtils.cbx2p<boolean>(x => fs.exists(filePath, x));

License

The MIT License (MIT)

Readme

Keywords

none

Package Sidebar

Install

npm i promise-utils-fl

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

4.09 kB

Total Files

5

Last publish

Collaborators

  • fabeuluci