Coder Social home page Coder Social logo

dizzy-promisify-bluebird's Introduction

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

dizzy-promisify-bluebird's People

Contributors

dependabot[bot] avatar fidian avatar greenkeeper[bot] avatar quantumew avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.