From 2a76b70757df38e06cb6162cd624706583da8ad3 Mon Sep 17 00:00:00 2001 From: Merilynn Bandy <31383109+furudean@users.noreply.github.com> Date: Wed, 8 Jun 2022 16:58:59 -0600 Subject: [PATCH] adds pMapSkip as an acceptable return value in Mapper type --- index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index f8972af..ba87496 100644 --- a/index.d.ts +++ b/index.d.ts @@ -44,6 +44,8 @@ export interface Options { readonly signal?: AbortSignal; } +type MaybePromise = T | Promise; + /** Function which is called for every item in `input`. Expected to return a `Promise` or value. @@ -53,7 +55,7 @@ Function which is called for every item in `input`. Expected to return a `Promis export type Mapper = ( element: Element, index: number -) => NewElement | Promise; +) => MaybePromise; /** @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.