Skip to content

Commit 5f7259c

Browse files
committed
move promiseModule argument into an option
fixes #28
1 parent 94c7861 commit 5f7259c

3 files changed

Lines changed: 13 additions & 16 deletions

File tree

index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ var processFn = function (fn, P, opts) {
3131
};
3232
};
3333

34-
var pify = module.exports = function (obj, P, opts) {
35-
if (typeof P !== 'function') {
36-
opts = P;
37-
P = Promise;
38-
}
39-
34+
var pify = module.exports = function (obj, opts) {
4035
opts = opts || {};
36+
37+
var P = opts.promiseModule || Promise;
4138
var exclude = opts.exclude || [/.+Sync$/];
4239

4340
var filter = function (key) {

readme.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pify(fs).readFile('package.json', 'utf8').then(data => {
3434

3535
## API
3636

37-
### pify(input, [promiseModule], [options])
37+
### pify(input, [options])
3838

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

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

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

47-
#### promiseModule
48-
49-
Type: `function`
50-
51-
Custom promise module to use instead of the native one.
52-
53-
Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.
54-
5547
#### options
5648

5749
##### multiArgs
@@ -113,6 +105,14 @@ if (promiseFn()) {
113105
}
114106
```
115107

108+
##### promiseModule
109+
110+
Type: `function`
111+
112+
Custom promise module to use instead of the native one.
113+
114+
Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.
115+
116116

117117
## License
118118

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('pass argument', async t => {
3737
});
3838

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

4343
test('multiArgs option', async t => {

0 commit comments

Comments
 (0)