Skip to content

Commit b58fc26

Browse files
authored
Add pMapSkip as an acceptable return value in Mapper type (#60)
1 parent 5ef93c2 commit b58fc26

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

index.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export interface Options {
4444
readonly signal?: AbortSignal;
4545
}
4646

47+
type MaybePromise<T> = T | Promise<T>;
48+
4749
/**
4850
Function which is called for every item in `input`. Expected to return a `Promise` or value.
4951
@@ -53,7 +55,7 @@ Function which is called for every item in `input`. Expected to return a `Promis
5355
export type Mapper<Element = any, NewElement = unknown> = (
5456
element: Element,
5557
index: number
56-
) => NewElement | Promise<NewElement>;
58+
) => MaybePromise<NewElement | typeof pMapSkip>;
5759

5860
/**
5961
@param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.

0 commit comments

Comments
 (0)