1.0.0 • Published 8 years ago

@jokeyrhyme/promisify v1.0.0

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
8 years ago

promisify.js

wrap a Node.js-style asynchronous function so that it returns a Promise

npm module Build Status

Usage

const promisify = require('@jokeyrhyme/promisify');

const fs = require('fs');

const readdir = promisify(fs.readdir);

fs.readdir(process.cwd())
  .then((result) => { /* ... */ })
  .catch((err) => { /* ... */ });

API

promisify (context?: Object, Function) => Promiser

interface Promiser {
  (...args: Any[]) => Promise
}

Related