injectpromise
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/injectpromise package

1.0.0 • Public • Published

injectpromise

A minimalistic package to insert a promise instead of using a callback.

Usage

 
const injectPromise = require('injectpromise')
 
class SomeClass {
 
    constructor() {
        this.injectPromise = injectPromise(this);
    }
 
    async getCurrent(callback = false) {
 
        if (!callback)
            return this.injectPromise(this.getCurrent);
 
        callSomething
            .then(result => {
            callback(null, result);
        }).catch(err => callback(err));
    }
 
}
 
module.exports = SomeClass
 
 

Readme

Keywords

none

Package Sidebar

Install

npm i injectpromise

Weekly Downloads

50,367

Version

1.0.0

License

MIT

Unpacked Size

1.3 kB

Total Files

3

Last publish

Collaborators

  • sullof