@ioredis/as-callback
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

Standard asCallback

A performant and standard (Bluebird) library that registers a node-style callback on a promise. It's used by ioredis.

Build Status npm latest version

Install

$ npm install @ioredis/as-callback

Usage

const asCallback = require('@ioredis/as-callback').defaults;

const promise = new Promise(function (resolve) {
  setTimeout(function () {
    resolve('hello world!')
  }, 1000)
})

asCallback(promise, function callback (err, res) {
  console.log(err, res) // null, 'hello world!'
})

Motivation

There are many libraries serve similar functionality. However, none of them I'd found are exactly the same as Bluebird's asCallback function (in terms of either performance or functionality). Thus this library comes out.

Thanks

Most code of this library are ported from the awesome Bluebird library.

License

The MIT License.

/@ioredis/as-callback/

    Package Sidebar

    Install

    npm i @ioredis/as-callback

    Weekly Downloads

    330,578

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    5.96 kB

    Total Files

    9

    Last publish

    Collaborators

    • ioredis-robot
    • luin