native-promisify
convert callback function to promise only use native promise
Last updated 12 years ago by coderhaoxin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install native-promisify 
SYNC missed versions from official npm registry.

Deprecated, please use thenify or thenify-all

NPM version Build status Test coverage License Dependency status

native-promisify

var promisify = require('native-promisify');
  • promisify function
function fn(ms, cb) {
  setTimeout(cb(null, ms), ms);
}

var p = promisify(fn);

p(10).then(function(ms) {
  console.log('delay: %d', ms);
});
  • promisify object
var obj = {
  name: 'hello',
  show: fun1,
  tell: fun2,
  ping: fun3
};

// promisify all functions (exclude generator function) of the object
promisify(origin);

// only promisify `show`, `tell`
promisify(origin, ['show', 'tell']);

// filter function
promisify(origin, function(key) {
  return key === 'ping';
});

License

MIT

Current Tags

  • 1.2.0                                ...           latest (12 years ago)

6 Versions

  • 1.2.0                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.3.0                                ...           12 years ago
  • 0.2.0                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 14
Today 0
This Week 0
This Month 7
Last Day 0
Last Week 6
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE