This package has been deprecated

Author message:

You should use utils/promisify instead

@jdes/promisify

1.1.61 • Public • Published

Promisify

Build Status Coverage Status

Promisify Node.js's callback functions and modules

Table of contents

Setup

This module can then be installed with npm:

npm install @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);
  });

/@jdes/promisify/

    Package Sidebar

    Install

    npm i @jdes/promisify

    Weekly Downloads

    0

    Version

    1.1.61

    License

    MIT

    Last publish

    Collaborators

    • jdes