mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[p-one] introduce typings (#18661)
This commit is contained in:
parent
01427d69a6
commit
c2ce1e4aba
16
types/p-one/index.d.ts
vendored
Normal file
16
types/p-one/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for p-one 1.0
|
||||
// Project: https://github.com/kevva/p-one#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = pOne;
|
||||
|
||||
declare function pOne<T>(input: Iterable<PromiseLike<T> | T>,
|
||||
testFn: (element: T, index: number) => boolean | Promise<boolean>,
|
||||
options?: pOne.Options): Promise<boolean>;
|
||||
|
||||
declare namespace pOne {
|
||||
interface Options {
|
||||
concurrency?: number;
|
||||
}
|
||||
}
|
||||
26
types/p-one/p-one-tests.ts
Normal file
26
types/p-one/p-one-tests.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import pOne = require('p-one');
|
||||
|
||||
const places = [
|
||||
Promise.resolve('Norway'),
|
||||
'Bangkok, Thailand',
|
||||
'Berlin, Germany',
|
||||
'Tokyo, Japan'
|
||||
];
|
||||
|
||||
pOne(places, x => Promise.resolve(true)).then(result => {
|
||||
const bool: boolean = result;
|
||||
});
|
||||
|
||||
const places2 = [
|
||||
Promise.resolve('Norway'),
|
||||
'Bangkok, Thailand',
|
||||
'Berlin, Germany',
|
||||
5
|
||||
];
|
||||
|
||||
pOne<string | number>(places2, x => {
|
||||
const strnum: string | number = x;
|
||||
return Promise.resolve(true);
|
||||
}, {concurrency: 2}).then(result => {
|
||||
const bool: boolean = result;
|
||||
});
|
||||
22
types/p-one/tsconfig.json
Normal file
22
types/p-one/tsconfig.json
Normal file
@ -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-one-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/p-one/tslint.json
Normal file
1
types/p-one/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user