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 🙏

© 2024 – Pkg Stats / Ryan Hefner

async-callback-promise-wrapper

v1.0.7

Published

Wraps any method that takes a callback to return a promise

Downloads

1

Readme

async-callback-promise-wrapper

Wraps any method that takes a callback to return a promise

async-callback-promise-wrapper is a swift wrapper that will wrap around your favourite function that requires a callback, and will return a method that returns a promise.

Installation

Package Manger

Using npm:

npm i async-callback-promise-wrapper

Documentation

Cjs Module
const MethodWrapper = require('async-callback-promise-wrapper')
Usage

Referring the method to be wrapped as exampleMethod

exampleMethod(input1, input2,..., callback);

Wrapping the exampleMethod.

const wrappedMethod = MethodWrapper(exampleMethod);

or

const wrappedMethod = MethodWrapper(exampleMethod,{...options});

Using the wrapped method.

let receivedPromise =  wrappedMethod(input1, input2,...);
Options

The method to be wrapped takes the input arguments first and then the callback

exampleMethod(input1,input2,...,callback)

then leave paramsOrder as undefined or provide paramsOrder:true in options

options = { ...otherOptions, paramsOrder:true}

The method to be wrapped takes the callback first and then the input arguments

exampleMethod(callback, input1, input2)

then provide paramsOrder:false in options

options = { ...otherOptions, paramsOrder:false}

The callback is required to take the result as first argument and the error as second argument

callback(res, err)

then leave callbackParamsOrder as undefined or provide callbackParamsOrder:true in options

options = {...otherOptions, callbackParamsOrder:true}

The callback is required to take the error as first argument and the result as second argument

callback(err, res)

then provide callbackParamsOrder:false in options

options = {...otherOptions, callbackParamsOrder:false}

The callback is required to take only the result. The method to be wrapped throws any errors directly.

callback(res);
exampleMethod(input1, input2, callback) throws Error

then leave callbackParamsOrder as undefined or provide callbackParamsOrder:true in options

options = {...otherOptions, callbackParamsOrder:true}

Supports

  • commonjs
  • node.js

Development

Want to contribute? Great!

async-callback-promise-wrapper is build using the latest technologies

Open your favorite Terminal and run these commands.

Install Dependencies

npm install

Run Tests

npm run test

Build

npm run build

Distribution files are present in the build folder.

License

MIT

Don't forget to Star on Github!