nodeify-ts
v1.0.6
Published
Create functions that both return promises and accept node-style callbacks
Downloads
48,361
Readme
nodeify-ts
Create functions that both return promises and accept node-style callbacks
Installation
npm install nodeify-ts
Usage
Javascript
var nodeify = require('nodeify-ts');
var command = function (command, callback) {
var promise = Promise.resolve().then(function () {
return Promise.resolve('do some work and return result ' + command);
}).then(function (data) {
return data;
});
return nodeify(promise, callback);
};
Typescript
import nodeify from 'nodeify-ts';
const command = function (command: string, callback?: (err, data) => void): Promise<any> {
const promise = Promise.resolve().then(function () {
return Promise.resolve('do some work and return result ' + command);
}).then(function (data) {
return data;
});
return nodeify(promise, callback);
};
License
MIT