mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-07 06:28:26 +08:00
Merge pull request #24064 from ibezkrovnyi/pify
[pify] include and exclude options should allow multiple entries (for TypeScript 2.7+)
This commit is contained in:
4
types/pify/index.d.ts
vendored
4
types/pify/index.d.ts
vendored
@@ -9,8 +9,8 @@ interface PromiseModule {
|
||||
|
||||
interface PifyOptions {
|
||||
multiArgs?: boolean,
|
||||
include?: [string | RegExp],
|
||||
exclude?: [string | RegExp],
|
||||
include?: Array<string | RegExp>,
|
||||
exclude?: Array<string | RegExp>,
|
||||
excludeMain?: boolean,
|
||||
errorFirst?: boolean,
|
||||
promiseModule?: PromiseModule
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user