Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
/ es6-promisifier-js Public archive

A Node.js module with a promisifier wrapper

License

Notifications You must be signed in to change notification settings

xpack/es6-promisifier-js

Repository files navigation

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.