Skip to main content
Deno 2 is finally here 🎉️
Learn more

promise_fns

Promise utility functions for Deno.

main semantic-release

Inspired by the sindresorhus promise-fun collection. Parity with the node promise-fun library is not guaranteed.

Features:

  • each function is independently importable
  • all typesafe, type reflecting APIs
  • concurrency control for most collection iterating functions
  • debuggable. simplified source, named functions (so your stack trace is legible!)

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
catchIf Conditional promise catch handler 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
event Await an event completion in a promise src test
if Conditional promise chains src test
log Log the resolved value of a promise src test
logCatch Log the rejected value of a promise 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
promisifyMulti 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
tap Tap into a resolving promise chain without affecting the resolved value src test
tapCatch Tap into a rejecting promise chain without affecting the rejected value src test

More functions are on their way.

contributing

Wanting to add more great stuff?. See .github/contributing.md