npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

await-resolver

v2.0.2

Published

An easy-to-use **async/await wrapper** to resolve any asynchronous tasks. Await-resolver always returns an array of type `[error, result]` **ensuring consistent error handling** and it provides **a timeout functionality to delay/timeout an execution**. Wi

Readme

Await Resolver

License NPM Package Version GitHub top language Size Last Commit Workflow CI

An easy-to-use async/await wrapper to resolve functions, promises, and any asynchronous task.

await-resolver always returns an array of type [error, result] ensuring consistent error handling across your code. You no longer have to use try/catch blocks or callbacks if you don't want to.

Additionally await-resolver provides a timeout functionality to delay/timeout an execution. You can use it as a sleep function.

Syntax:

await resolver(something)

await resolver(something, timeout)

await resolver(fn, timeout, fn_param1, fn_param2, ..., fn_paramN)

await resolver.sleep(timeout)

Or as a promise

resolver(something).then(([result, error]) => { ... })

resolver(something, timeout).then(([result, error]) => { ... })

resolver(fn, timeout, fn_param1, fn_param2, ..., fn_paramN).then(([result, error]) => { ... })

resolver.sleep(timeout).then(([result, error]) => { ... })

Installation

$ npm install await-resolver

Usage

Require CommonJS (default)
const resolver = require("await-resolver");
Import ES-Module (default)
import resolver from "await-resolver";
Import ES-Module (named)
import { resolver } from "await-resolver";

Await the resolver

// If you environment does not support top-level await,
// wrap everything in an async function.

// await-resolve a fetch result
const fetchRequest = fetch(urlOrRequest[, options]);

// in one go
let [error, data] = await resolver(fetchRequest.then(res => res.json()));

// or step by step
let [responseError, response] = await resolver(fetchRequest);
if(responseError){
    // return early
}
let [dataError, data] = await resolver(response.json());



// await-resolve anything: a function, a promise, an error, or any kind of value
let [error, result] = await resolver(anything);

// Use timeout to delay execution
let timeout = 1500; // ms just like setTimeout

// just sleep
await resolver(null, timeout);

// Resolve a function without arguments, with timeout
let [error, result] = await resolver(my_function, timeout);

// Resolve a function with arguments, without timeout
let multiply = (a, b) => a * b;
let [error, result] = await resolver(multiply, null, 4, 5); // => [null, 20]

// Resolve a function with arguments, with timeout
let [error, result] = await resolver(multiply, timeout, 4, 5); // => [null, 20] after timeout

Or use the resolver as a regular promise

resolver(anything).then(([error, result]) => {
    if (error) {
        // do something
    } else {
        // do something else
    }
});

// sleep
resolver(null, timeout).then(([error, result]) => {
    // do something
});

let multiply = (a, b) => a * b;

resolver(multiply, timeout, 4, 5).then(([error, result]) => {
    // do something
});

License

See LICENSE.

Copyright

Copyright © 2022. Kossi D. T. Saka.