0.0.3 • Published 7 years ago

promisiphy v0.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Simple ES6 promisifier

Turns old-style-callback function to the Promise-style one

Basic usage

const promisify = require('promisiphy');
const fs = require('fs');

promisify(fs, 'stat', 'path/to/the/file')
  .then(result => {
      console.log(result);
  })
  .catch(error => {
      console.error(error);
  });

Providing a context

const promisify = require('promisiphy');
const http = require('http');

promisify(http, 'get', 'http://some.url', {ctx: http})
  .then(result => {
      console.log(result);
  })
  .catch(error => {
      console.error(error);
  });