From fa0acf4ba18b1a247055700b0a9e1a6585227662 Mon Sep 17 00:00:00 2001 From: Igor Bezkrovnyi <1188919+ibezkrovnyi@users.noreply.github.com> Date: Sat, 3 Mar 2018 23:42:29 +0100 Subject: [PATCH] include and exclude options support multiple entries --- types/pify/index.d.ts | 4 ++-- types/pify/pify-tests.ts | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/types/pify/index.d.ts b/types/pify/index.d.ts index fc4b13df5d..b0c8ce4b92 100644 --- a/types/pify/index.d.ts +++ b/types/pify/index.d.ts @@ -9,8 +9,8 @@ interface PromiseModule { interface PifyOptions { multiArgs?: boolean, - include?: [string | RegExp], - exclude?: [string | RegExp], + include?: Array, + exclude?: Array, excludeMain?: boolean, errorFirst?: boolean, promiseModule?: PromiseModule diff --git a/types/pify/pify-tests.ts b/types/pify/pify-tests.ts index 27022b7390..cadf3ba408 100644 --- a/types/pify/pify-tests.ts +++ b/types/pify/pify-tests.ts @@ -31,3 +31,20 @@ pify(fs.readFile, { promiseModule: Promise})('bar.txt').then((result: string) => pify(fs.exists, { errorFirst: false })('foo.txt').then((result: boolean) => assert(result.toString(), true.toString())); + +// include/exclude with multiple entries +const module = { + f1: (callback: Function) => callback(), + f2: (callback: Function) => callback(), + f3: (callback: Function) => callback(), +}; + +const include = pify(module, { include: ['f1', 'f2'] }); +if (include.f1 === module.f1) throw new Error(); +if (include.f2 === module.f2) throw new Error(); +if (include.f3 !== module.f3) throw new Error(); + +const exclude = pify(module, { exclude: ['f1', 'f2'] }); +if (include.f1 !== module.f1) throw new Error(); +if (include.f2 !== module.f2) throw new Error(); +if (include.f3 === module.f3) throw new Error();