mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[p-locate] introduce typings (#18718)
This commit is contained in:
parent
3c43f5038a
commit
40295264aa
15
types/p-locate/index.d.ts
vendored
Normal file
15
types/p-locate/index.d.ts
vendored
Normal 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;
|
||||
}
|
||||
}
|
||||
14
types/p-locate/p-locate-tests.ts
Normal file
14
types/p-locate/p-locate-tests.ts
Normal 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});
|
||||
22
types/p-locate/tsconfig.json
Normal file
22
types/p-locate/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-locate-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/p-locate/tslint.json
Normal file
1
types/p-locate/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user