v1.0.1
Promise utility functions for Deno
Repository
Current version released
4 years ago
promise_fns
Promise utility functions for Deno.
Inspired by the sindresorhus
promise-fun collection. Parity
with the node promise-fun
library is not guaranteed.
Features:
- each function is independently importable
- all APIs are type-safe first
usage
You can import any individual function as follows:
import fn from "https://deno.land/x/promise_fns/src/FUNCTION_NAME.ts";
fn(...)
All functions are listed in the functions table.
A full example:
import delay from "https://deno.land/x/promise_fns/src/delay.ts";
const delayedTwo = await delay(100, 2);
console.log(1 + delayedTwo); // 3
functions
function | description | links |
---|---|---|
all | resolve an eager or lazy collection of promises | src test |
delay | create a promise that sleeps for some milliseconds then resolves | src test |
delayReject | create a promise that sleeps for some milliseconds then rejects | src test |
map | maps a collection into a new collection asynchronously | src test |
promisify | converts a node-style callback function into a promisified function, returning the result after err , per (err, result) => void |
src test |
promisify-multi | converts a node-style callback function into a promisified function, returning all results after err , per (err, ...results) => void |
src test |
props | maps a { key:promise } mapped collection to a { key:resolved-promise } mapped collection | src test |
queue | creates a queue that allows users to add work. queue resolves when no work is outstanding | src test |