Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.
/ promisify Public archive

💫 Promisify Node's callback functions and modules

License

Notifications You must be signed in to change notification settings

jeandesravines/promisify

Repository files navigation

Promisify

Build Status codecov

/!\ Deprecated /!
Promisify Node.js's callback functions and modules

Table of contents

Setup

This module can then be installed with yarn:

yarn add @jdes/promisify

Usage

Import module

/**
 * @type {Function}
 */
const promisify = require('@jdes/promisify');

Promisify a module by name

/**
* @type {Object}
*/
const fs = promisify('fs');

Promisify a function

/**
 * @type {Object}
 */
const fs = require('fs');

/**
 * @type {Object}
 */
const promisify = require('@jdes/promisify');

/**
 * @type {function}
 */
const readFile = promisify(fs.readFile);

API

promisify(data: Object | string | function): function(...[*]): Promise

Example

// Import the modue
const promisify = require('@jdes/promisify');

// Promisify by module name
const fs = promisify('fs');

// read file
fs.readFile('/dev/null')
  .then((data) => {
    console.log(data);
  })
  .catch((error) => {
    console.error(error);
  });

About

💫 Promisify Node's callback functions and modules

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published