mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Add type definitions for promise-map-limit package (#25550)
* Add type definitions for map-promise-limit library * map-promise-limit → promise-map-limit A typo…sigh. The GitHub repository link to promise-map-limit was previously correct, however. * Remove additional TSLint rule Thanks @plantain-00!
This commit is contained in:
committed by
Sheetal Nandi
parent
0af74afc17
commit
92251a67c8
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -3009,6 +3009,7 @@
|
||||
/types/proj4leaflet/ @BendingBender
|
||||
/types/project-oxford/ @scsouthw
|
||||
/types/promise-dag/ @OSjoerdWie
|
||||
/types/promise-map-limit/ @kohlmannj
|
||||
/types/promise-pg/ @coldacid
|
||||
/types/promise-polyfill/ @skysteve
|
||||
/types/promise-pool/ @vilic
|
||||
|
||||
17
types/promise-map-limit/index.d.ts
vendored
Normal file
17
types/promise-map-limit/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Type definitions for promise-map-limit 1.0
|
||||
// Project: https://github.com/dbrockman/promise-map-limit
|
||||
// Definitions by: Joseph Kohlmann <https://github.com/kohlmannj>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export = promiseMapLimit;
|
||||
|
||||
declare function promiseMapLimit<T, R>(
|
||||
iterable: Iterable<T>,
|
||||
concurrency: number,
|
||||
iteratee: promiseMapLimit.IIteratee<T, R>
|
||||
): Promise<R[]>;
|
||||
|
||||
declare namespace promiseMapLimit {
|
||||
type IIteratee<T, R> = (value: T) => Promise<R> | R;
|
||||
}
|
||||
26
types/promise-map-limit/promise-map-limit-tests.ts
Normal file
26
types/promise-map-limit/promise-map-limit-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import mapPromiseLimit = require('promise-map-limit');
|
||||
|
||||
const promisedStrings = mapPromiseLimit(['foo', 'bar'], 2, s => s);
|
||||
promisedStrings; // $ExpectType Promise<string[]>
|
||||
|
||||
const promisedBooleans = mapPromiseLimit([true, false], 2, b => b);
|
||||
promisedBooleans; // $ExpectType Promise<boolean[]>
|
||||
|
||||
const promiseOfPromisedNumbers = mapPromiseLimit(
|
||||
[{ foo: 1 }, { foo: 2 }],
|
||||
2,
|
||||
value => Promise.resolve(value.foo),
|
||||
);
|
||||
promiseOfPromisedNumbers; // $ExpectType Promise<number[]>
|
||||
|
||||
const promiseNumber = (value: Record<string, number>): Promise<number> =>
|
||||
new Promise((resolve, reject) => { resolve(value.foo); });
|
||||
|
||||
(async () => {
|
||||
const asyncNumbers = await mapPromiseLimit(
|
||||
[{ foo: 1 }, { foo: 2 }],
|
||||
2,
|
||||
async value => promiseNumber(value),
|
||||
);
|
||||
asyncNumbers; // $ExpectType number[]
|
||||
})();
|
||||
23
types/promise-map-limit/tsconfig.json
Normal file
23
types/promise-map-limit/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"promise-map-limit-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/promise-map-limit/tslint.json
Normal file
3
types/promise-map-limit/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user