Skip to content

Commit f59ff8e

Browse files
committed
feat(dropWhile): accept a predicate that returns a Promise
1 parent 1355ada commit f59ff8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ export const asyncTakeUntilFn = takeUntilFn;
255255

256256
export async function* dropWhile<T>(
257257
iterable: AsyncIterableLike<T>,
258-
predicate: (element: T, index: number) => boolean
258+
predicate: (element: T, index: number) => boolean | Promise<boolean>
259259
): AsyncIterable<T> {
260260
const iterator = asyncIterator(iterable);
261261
let result = await iterator.next();
262-
for (let i = 0; result.done !== true && predicate(result.value, i); ++i) {
262+
for (let i = 0; result.done !== true && (await predicate(result.value, i)); ++i) {
263263
result = await iterator.next();
264264
}
265265

@@ -272,7 +272,7 @@ export async function* dropWhile<T>(
272272
export const asyncDropWhile = dropWhile;
273273

274274
export function dropWhileFn<T>(
275-
predicate: (element: T, index: number) => boolean
275+
predicate: (element: T, index: number) => boolean | Promise<boolean>
276276
): (iterable: AsyncIterableLike<T>) => AsyncIterable<T> {
277277
return iterable => dropWhile(iterable, predicate);
278278
}

0 commit comments

Comments
 (0)