[p-one] introduce typings (#18661)

This commit is contained in:
Dimitri Benin 2017-08-08 23:21:22 +02:00 committed by Mohamed Hegazy
parent 01427d69a6
commit c2ce1e4aba
4 changed files with 65 additions and 0 deletions

16
types/p-one/index.d.ts vendored Normal file
View 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;
}
}

View 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
View 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
View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }