diff --git a/types/p-map/index.d.ts b/types/p-map/index.d.ts new file mode 100644 index 0000000000..ccaf32e711 --- /dev/null +++ b/types/p-map/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for p-map 1.1 +// Project: https://github.com/sindresorhus/p-map#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export = pMap; + +declare function pMap(input: Iterable>, mapper: Mapper, options?: pMap.Options): Promise; + +type Input = Promise | PromiseLike | T; +type Mapper = (el: T, index: number) => Promise | R; + +declare namespace pMap { + interface Options { + concurrency?: number; + } +} diff --git a/types/p-map/p-map-tests.ts b/types/p-map/p-map-tests.ts new file mode 100644 index 0000000000..48d4ed5e5a --- /dev/null +++ b/types/p-map/p-map-tests.ts @@ -0,0 +1,18 @@ +import pMap = require('p-map'); + +const sites = [ + Promise.resolve('sindresorhus'), + true, + 1 +]; + +const mapper = (el: number | string | boolean) => Promise.resolve(1); + +let num: number; +pMap(sites, mapper, {concurrency: 2}).then(result => { + num = result[3]; +}); + +pMap(sites, mapper).then(result => { + num = result[3]; +}); diff --git a/types/p-map/tsconfig.json b/types/p-map/tsconfig.json new file mode 100644 index 0000000000..92e08792e2 --- /dev/null +++ b/types/p-map/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "p-map-tests.ts" + ] +} diff --git a/types/p-map/tslint.json b/types/p-map/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/p-map/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }