nodeify-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

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

Package Sidebar

Install

npm i nodeify-ts

Weekly Downloads

12,623

Version

1.0.6

License

MIT

Unpacked Size

4.33 kB

Total Files

5

Last publish

Collaborators

  • mattqs