[p-locate] introduce typings (#18718)

This commit is contained in:
Dimitri Benin 2017-08-08 23:01:12 +02:00 committed by Mohamed Hegazy
parent 3c43f5038a
commit 40295264aa
4 changed files with 52 additions and 0 deletions

15
types/p-locate/index.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
// Type definitions for p-locate 2.0
// Project: https://github.com/sindresorhus/p-locate#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = pLocate;
declare function pLocate<T>(input: Iterable<PromiseLike<T> | T>, tester: (element: T) => Promise<boolean> | boolean, options?: pLocate.Options): Promise<T | undefined>;
declare namespace pLocate {
interface Options {
concurrency?: number;
preserveOrder?: boolean;
}
}

View File

@ -0,0 +1,14 @@
import pLocate = require('p-locate');
const files = [
'unicorn.png',
'rainbow.png',
'pony.png'
];
let str: string | undefined;
pLocate(files, file => Promise.resolve(file === 'rainbow.png')).then(foundPath => {
str = foundPath;
});
pLocate(files, file => Promise.resolve(file === 'rainbow.png'), {concurrency: 2, preserveOrder: false});

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-locate-tests.ts"
]
}

View File

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