isify

0.1.1 • Public • Published

Isify

Turn an asynchronous function with an expected last parameter callback function of form (err, result) => {...} into a promise that will throw the non-falsy error if present or send the results forward into then.

npm install --save isify

Example

const fs = require('fs')
const isify = require('isify')

// write "Hello World" to local file fileToWrite.txt
isify(fs.writeFile, './fileToWrite.txt', 'Hello World')
  .then(() => {
    console.log('Wrote file')
  })
  .catch(err => {
    console.log('Failed to write with error:', err)
  })

Readme

Keywords

Package Sidebar

Install

npm i isify

Weekly Downloads

13

Version

0.1.1

License

MIT

Last publish

Collaborators

  • dbunker