From 397e77cd0c244067bc04ea4198991ab0b6244161 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Sun, 23 Jul 2023 13:17:42 +1200 Subject: [PATCH] Add use case Signed-off-by: Richie Bendall --- index.d.ts | 2 ++ readme.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/index.d.ts b/index.d.ts index 9517809..425abe5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -48,6 +48,8 @@ export type IterableOptions = BaseOptions & { /** Maximum number of promises returned by `mapper` that have resolved but not yet collected by the consumer of the async iterable. Calls to `mapper` will be limited so that there is never too much backpressure. + Useful whenever you are consuming the iterable slower than what the mapper function can produce concurrently. For example, to avoid making an overwhelming number of HTTP requests if you are saving each of the results to a database. + Default: `options.concurrency` */ readonly backpressure?: number; diff --git a/readme.md b/readme.md index f1f95d2..42caed4 100644 --- a/readme.md +++ b/readme.md @@ -90,6 +90,8 @@ Minimum: `options.concurrency` Maximum number of promises returned by `mapper` that have resolved but not yet collected by the consumer of the async iterable. Calls to `mapper` will be limited so that there is never too much backpressure. +Useful whenever you are consuming the iterable slower than what the mapper function can produce concurrently. For example, to avoid making an overwhelming number of HTTP requests if you are saving each of the results to a database. + ##### stopOnError **Only for `pMap`**