Skip to content

Create functions that both return promises and accept node-style callbacks

License

Notifications You must be signed in to change notification settings

Quobject/nodeify-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodeify-ts

Create functions that both return promises and accept node-style callbacks

NPM version NPM downloads Build status Gitter

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

About

Create functions that both return promises and accept node-style callbacks

Resources

License

Stars

Watchers

Forks

Packages

No packages published