-
Notifications
You must be signed in to change notification settings - Fork 3
/
readme.hbs
45 lines (31 loc) · 1.07 KB
/
readme.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# promisify-call
[![npm version](https://img.shields.io/npm/v/promisify-call.svg?style=flat-square)](https://www.npmjs.com/package/promisify-call)
[![build status](https://img.shields.io/travis/bojand/promisify-call/master.svg?style=flat-square)](https://travis-ci.org/bojand/promisify-call)
Promisify a function call so users can call a function with a callback or get a promise.
* **2.0** works only with native `Promise` so requires Node >= 4.0.
* **1.0** uses [Bluebird](www.bluebirdjs.com) and should work with older Node.js
## Installation
`npm install promisify-call`
## Usage
```js
function _uppercase(param, fn) {
setTimeout(() => {
return fn(null, param.toUpperCase());
}, 50);
}
function uppercase(param, fn) {
return promisifyCall(this, _uppercase, ...arguments);
}
// now we can call it using callback-style
uppercase('foo', (err, res) => {
console.log(res); // FOO
});
// OR promise style
const res = await uppercase('foo');
console.log(res); // FOO
```
## API Reference
{{>all-docs~}}
## License
Copyright 2015 Bojan D.
Licensed under the MIT License.