@xpack/es6-promisifier

1.0.1 • Public • Published

npm (scoped) license Standard Actions Status GitHub issues GitHub pulls

An ES6 promisifier wrapper

A Node.js module with a class providing a static function to wrap standard Node.js callback functions into ES6 promises.

Prerequisites

A recent Node.js (>7.x), since the ECMAScript 6 class syntax is used.

Easy install

The module is available as @xpack/es6-promisifier from the public repository, use npm to install it inside the module where it is needed:

$ npm install @xpack/es6-promisifier

The module does not provide any executables, and generally there are few reasons to install it globally.

The development repository is available from the GitHub xpack/es6-promisifier-js project.

User info

This section is intended for those who want to use this module in their own projects.

The module can be included in any applications and the Promisifier class can be used to access the promisify() functions.

const Promisifier = require('@xpack/es6-promisifier').Promisifier

// Promisify functions from the Node.js callbacks library.
// The new functions have similar names, but suffixed with `Promise`,
// or below a `promises` object.
Promisifier.promisifyInPlace(fs, 'open')

// New use case:
//   const fsPromises = fs.promises_
//   await fsPromises.open()

// Old use case:
//   await fs.openPromise()

// Note: using `promises_` is a workaround to avoid the `fs.promises`
// warning.

// Promisify a single function from a third party simple module.
const mkdirpPromise = Promisifier.promisify(require('mkdirp'))

Maintainer info

This page documents how to use this module in an user application. For maintainer information, see the separate README-MAINTAINER page.

License

The original content is released under the MIT License, with all rights reserved to Liviu Ionescu.

/@xpack/es6-promisifier/

    Package Sidebar

    Install

    npm i @xpack/es6-promisifier

    Weekly Downloads

    69

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    14.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • ilg