Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c23071
commit 9dfc688
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
definitions/npm/p-filter_v1.x.x/flow_v0.70.x-/p-filter_v1.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
declare module 'p-filter' { | ||
declare export default function PFilter<T>( | ||
input: Iterable<Promise<T> | T>, | ||
filterer: (element: T, index: number) => boolean | Promise<boolean>, | ||
options?: { concurrency?: number }, | ||
): Promise<Array<T>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pFilter from 'p-filter'; | ||
import { it } from 'flow-typed-test'; | ||
|
||
it('handles correct inputs and return type', () => { | ||
(pFilter([1, 2, 3], (el: number, index: number) => true): Promise< | ||
Array<number>, | ||
>); | ||
(pFilter( | ||
['a', 'b', Promise.resolve('c')], | ||
(el: string, index: number) => false, | ||
{ concurrency: 2 }, | ||
): Promise<Array<string>>); | ||
}); | ||
|
||
it('errors on invalid filterer element type', () => { | ||
// $ExpectError | ||
pFilter(['a', 'b', Promise.resolve(3)], (el: string, index: number) => true); | ||
}); | ||
|
||
it('errors on invalid filterer return type', () => { | ||
// $ExpectError | ||
pFilter([1, 2, Promise.resolve(3)], (el: number, index: number) => null); | ||
}); | ||
|
||
it('errors on invalid return type', () => { | ||
// $ExpectError | ||
(pFilter([1, 2, 3], (el: number, index: number) => true): Promise< | ||
Array<string>, | ||
>); | ||
}); | ||
|
||
it('errors on invalid options', () => { | ||
// $ExpectError | ||
pFilter([1, 2, 3], (el: number, index: number) => true, { concurrency: '1' }); | ||
}); |