native-promisify

1.2.0 • Public • Published

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

Package Sidebar

Install

npm i native-promisify

Weekly Downloads

126

Version

1.2.0

License

MIT

Last publish

Collaborators

  • coderhaoxin