Skip to content
Permalink
Browse files
Exclude methods ending in Stream by default
Fixes #37
  • Loading branch information
sindresorhus committed Apr 18, 2017
1 parent 65fa820 commit a2cec4cb0cb0fbe398123e76b1ce30e8a9943be4
Showing 3 changed files with 7 additions and 2 deletions.
@@ -37,7 +37,7 @@ const processFn = (fn, opts) => function () {

module.exports = (obj, opts) => {
opts = Object.assign({
exclude: [/.+Sync$/],
exclude: [/.+(Sync|Stream)$/],
promiseModule: Promise
}, opts);

@@ -71,7 +71,7 @@ Methods in a module to promisify. Remaining methods will be left untouched.
##### exclude

Type: `string[]` `RegExp[]`<br>
Default: `[/.+Sync$/]`
Default: `[/.+(Sync|Stream)$/]`

Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default.

@@ -1,4 +1,5 @@
import fs from 'fs';
import stream from 'stream';
import test from 'ava';
import pinkiePromise from 'pinkie-promise';
import m from '.';
@@ -63,6 +64,10 @@ test('module support - doesn\'t transform *Sync methods by default', t => {
t.is(JSON.parse(m(fs).readFileSync('package.json')).name, 'pify');
});

test('module support - doesn\'t transform *Stream methods by default', t => {
t.true(m(fs).createReadStream('package.json') instanceof stream.Readable);
});

test('module support - preserves non-function members', t => {
const module = {
method: () => {},

0 comments on commit a2cec4c

Please sign in to comment.