# promisify-es6

> Promisify callback-style functions to ES6 promises

Latest version **1.0.3** (published 2017-07-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install promisify-es6
pnpm add promisify-es6
yarn add promisify-es6
bun add promisify-es6
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-07-26 |
| First published | 2016-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Manuel Di Iorio |
| Maintainers | xeryan |
| Keywords | promise, promisify, es6, function, callback |

## Links

- npm: https://www.npmjs.com/package/promisify-es6
- Repository: https://github.com/manuel-di-iorio/promisify-es6
- Homepage: https://github.com/manuel-di-iorio/promisify-es6#readme
- Issues: https://github.com/manuel-di-iorio/promisify-es6/issues
- npm.io page: https://npm.io/package/promisify-es6

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2017-07-26
- 1.0.2 — 2016-09-14
- 1.0.1 — 2016-04-02

## README

**NOTE:** Starting from Node.js v.8.0.0, the promisify method is now included in the `util` native library.

On Node.js, the usage of the native method is recommended!

```
// Native promisify example
const util = require('util');
const readfile = util.promisify(fs.readFile);
```

# ES6 Promisify
## This is a library to promisify callback-style functions to ES6 promises. You can also use it on the client-side.

### Install it with:

    npm i --save promisify-es6
    or
    git clone https://github.com/manuel-di-iorio/promisify-es6.git

### Example:

```javascript
var promisify = require("promisify-es6");
var fs = require("fs");
var readFile = promisify(fs.readFile);

readFile("test.js")
 .then(function(content) {
    console.log(content.toString());
 })
 .catch(function(err) {
    console.error(err);
 });
```

A promisified function is still callable with the callback style:

```javascript
readFile("test.js", function(err, content) { //etc...
```

You can even promisify entire modules or arrays:

```javascript
var readFile = promisify(require("fs")).readFile;
```

## API

```javascript
promisify(method[, options])
```
    *Method* can be a function or an array/map of functions to promisify

    *Options* can have the following properties:

        `context`: The context which to apply the called function (by default is the function itself)
        `replace`: When an array/map is passed and this is truthy, it will replace the original object

### Test with Mocha:

    npm test

---
_Source: https://npm.io/package/promisify-es6 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
