From 4cce4de19ed577f481ba45a023b395a29cadce86 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 6 Mar 2021 19:34:58 +0700 Subject: [PATCH] Fix docs being out of sync from #1645 --- readme.md | 3 ++- source/as-promise/types.ts | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index bc2a0cb2f..49ef5b081 100644 --- a/readme.md +++ b/readme.md @@ -1026,8 +1026,9 @@ Default: `false` Defines how the property `allItems` in [`pagination.paginate`](#pagination.paginate), [`pagination.filter`](#pagination.filter) and [`pagination.shouldContinue`](#pagination.shouldContinue) is managed. -When set to `false`, the `allItems` parameter is always an empty array. If `true`, it can hugely increase memory usage when working with a large dataset. +By default, the property `allItems` is always an empty array. This setting can be helpful to save on memory usage when working with a large dataset. +When set to `true`, the property `allItems` is an array of the emitted items. ##### localAddress diff --git a/source/as-promise/types.ts b/source/as-promise/types.ts index 56203bae1..e9d27443f 100644 --- a/source/as-promise/types.ts +++ b/source/as-promise/types.ts @@ -47,11 +47,9 @@ export interface PaginationOptions { The function takes an object with the following properties: - `response` - The current response object. - `currentItems` - Items from the current response. - - `allItems` - An empty array, unless when `pagination.stackAllItems` is set to `true`. In the later case, an array of the emitted items. + - `allItems` - An empty array, unless `pagination.stackAllItems` is set to `true`, in which case, it's an array of the emitted items. - It should return an object representing Got options pointing to the next page. - The options are merged automatically with the previous request, therefore the options returned `pagination.paginate(...)` must reflect changes only. - If there are no more pages, `false` should be returned. + It should return an object representing Got options pointing to the next page. The options are merged automatically with the previous request, therefore the options returned `pagination.paginate(...)` must reflect changes only. If there are no more pages, `false` should be returned. @example ``` @@ -126,11 +124,13 @@ export interface PaginationOptions { requestLimit?: number; /** - Defines how the property `allItems` in pagination.paginate, pagination.filter and pagination.shouldContinue is managed. + Defines how the property `allItems` in `pagination.paginate`, `pagination.filter` and `pagination.shouldContinue` is managed. By default, the property `allItems` is always an empty array. This setting can be helpful to save on memory usage when working with a large dataset. When set to `true`, the property `allItems` is an array of the emitted items. + + @default false */ stackAllItems?: boolean; };