Skip to content

Commit

Permalink
move promiseModule argument into an option
Browse files Browse the repository at this point in the history
fixes #28
  • Loading branch information
sindresorhus committed Sep 16, 2016
1 parent 94c7861 commit 5f7259c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ var processFn = function (fn, P, opts) {
};
};

var pify = module.exports = function (obj, P, opts) {
if (typeof P !== 'function') {
opts = P;
P = Promise;
}

var pify = module.exports = function (obj, opts) {
opts = opts || {};

var P = opts.promiseModule || Promise;
var exclude = opts.exclude || [/.+Sync$/];

var filter = function (key) {
Expand Down
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pify(fs).readFile('package.json', 'utf8').then(data => {

## API

### pify(input, [promiseModule], [options])
### pify(input, [options])

Returns a promise wrapped version of the supplied function or module.

Expand All @@ -44,14 +44,6 @@ Type: `function`, `object`

Callback-style function or module whose methods you want to promisify.

#### promiseModule

Type: `function`

Custom promise module to use instead of the native one.

Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.

#### options

##### multiArgs
Expand Down Expand Up @@ -113,6 +105,14 @@ if (promiseFn()) {
}
```

##### promiseModule

Type: `function`

Custom promise module to use instead of the native one.

Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.


## License

Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test('pass argument', async t => {
});

test('custom Promise module', async t => {
t.is(await fn(fixture, pinkiePromise)(), 'unicorn');
t.is(await fn(fixture, {promiseModule: pinkiePromise})(), 'unicorn');
});

test('multiArgs option', async t => {
Expand Down

0 comments on commit 5f7259c

Please sign in to comment.