1.1.2 • Published 3 years ago

dizzy-promisify-bluebird v1.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

Dizzy-Promisify-Bluebird

When you use Dizzy to perform dependency injection you could also want the things to use promises. For instance, using fs.readFile() can get you into a mess with callbacks. By leveraging Bluebird, you can make all node-style callback functions return promises. That call to fs.readFile() turns into fs.readFileAsync() and you've started a promise chain.

npm version Build Status Dependencies Dev Dependencies codecov.io

Overview

First, you will likely want to get Dizzy up and running.

var container, Dizzy;

Dizzy = require('dizzy');

Next, call the plugin and pass in your reference to Dizzy.

require('dizzy-promisify-bluebird')(Dizzy);

Make your container.

container = new Dizzy();

Finally, register some modules to be promisified.

// One module
container.register("fsAsync", "fs").fromModule().promisified().cached();

// Multiple modules
container.registerBulk({
    cryptoAsync: "crypto",
    globAsync: "glob",
    zlibAsync: "zlib"
}).fromModule().promisified().cached();

Want to use TypeScript?

import { default as Dizzy } from 'dizzy';
import { default as dizzyPromisifyBluebird } from 'dizzy-promisify-bluebird';

dizzyPromisifyBluebird(Dizzy);
container = new Dizzy();
// and then use your container.

Installation

Use npm to install this package easily.

$ npm install --save dizzy-promisify-bluebird

Alternately you may edit your package.json and add this to your dependencies object:

{
    ...
    "dependencies": {
        ...
        "dizzy-promisify-bluebird": "*"
        ...
    }
    ...
}

License

This software is licensed under a MIT license that contains an additional non-advertising clause. Read full license terms

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago