diff --git a/README.md b/README.md index 25c1bf560..45bbb60ef 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ In addition to skipping unnecessary recalculations, `memoizedSelectCompletedTodo - [**`createSelector`**][`createSelector`] - [**`createSelectorCreator`**][`createSelectorCreator`] - [**`createStructuredSelector`**][`createStructuredSelector`] - - [**`defaultMemoize`**][`defaultMemoize`] + - [**`lruMemoize`**][`lruMemoize`] - [**`weakMapMemoize`**][`weakMapMemoize`] - [**`unstable_autotrackMemoize`**][`unstable_autotrackMemoize`] - [Debugging Tools](#debuggingtools) @@ -348,18 +348,18 @@ Accepts either a `memoize` function and `...memoizeOptions` rest parameter, or s | Name | Description | | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `options` | An options object containing the `memoize` function responsible for memoizing the `resultFunc` inside [`createSelector`] (e.g., `defaultMemoize` or `weakMapMemoize`). It also provides additional options for customizing memoization. While the `memoize` property is mandatory, the rest are optional. | -| `options.argsMemoize?` | The optional memoize function that is used to memoize the arguments passed into the [output selector] generated by [`createSelector`] (e.g., `defaultMemoize` or `weakMapMemoize`).
**`Default`** `defaultMemoize` | +| `options` | An options object containing the `memoize` function responsible for memoizing the `resultFunc` inside [`createSelector`] (e.g., `lruMemoize` or `weakMapMemoize`). It also provides additional options for customizing memoization. While the `memoize` property is mandatory, the rest are optional. | +| `options.argsMemoize?` | The optional memoize function that is used to memoize the arguments passed into the [output selector] generated by [`createSelector`] (e.g., `lruMemoize` or `weakMapMemoize`).
**`Default`** `lruMemoize` | | `options.argsMemoizeOptions?` | Optional configuration options for the `argsMemoize` function. These options are passed to the `argsMemoize` function as the second argument.
since 5.0.0 | | `options.devModeChecks?` | Overrides the settings for the global development mode checks for the selector.
since 5.0.0 | -| `options.memoize` | The memoize function that is used to memoize the `resultFunc` inside [`createSelector`] (e.g., `defaultMemoize` or `weakMapMemoize`). since 5.0.0 | +| `options.memoize` | The memoize function that is used to memoize the `resultFunc` inside [`createSelector`] (e.g., `lruMemoize` or `weakMapMemoize`). since 5.0.0 | | `options.memoizeOptions?` | Optional configuration options for the `memoize` function. These options are passed to the `memoize` function as the second argument.
since 5.0.0 | Parameters | Name | Description | | :-------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- | -| `memoize` | The `memoize` function responsible for memoizing the `resultFunc` inside [`createSelector`] (e.g., `defaultMemoize` or `weakMapMemoize`). | +| `memoize` | The `memoize` function responsible for memoizing the `resultFunc` inside [`createSelector`] (e.g., `lruMemoize` or `weakMapMemoize`). | | `...memoizeOptionsFromArgs` | Optional configuration options for the memoization function. These options are then passed to the memoize function as the second argument onwards. | Returns @@ -370,8 +370,8 @@ A customized [`createSelector`] function. | Name | Description | | :-------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `MemoizeFunction` | The type of the memoize function that is used to memoize the `resultFunc` inside [`createSelector`] (e.g., `defaultMemoize` or `weakMapMemoize`). | -| `ArgsMemoizeFunction` | The type of the optional memoize function that is used to memoize the arguments passed into the [output selector] generated by [`createSelector`] (e.g., `defaultMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. | +| `MemoizeFunction` | The type of the memoize function that is used to memoize the `resultFunc` inside [`createSelector`] (e.g., `lruMemoize` or `weakMapMemoize`). | +| `ArgsMemoizeFunction` | The type of the optional memoize function that is used to memoize the arguments passed into the [output selector] generated by [`createSelector`] (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. | @@ -431,14 +431,14 @@ customMemoize(resultFunc, option1, option2, option3) ##### Additional Examples -###### Customize `equalityCheck` for `defaultMemoize` +###### Customize `equalityCheck` for `lruMemoize` ```js -import { createSelectorCreator, defaultMemoize } from 'reselect' +import { createSelectorCreator, lruMemoize } from 'reselect' import isEqual from 'lodash.isequal' // create a "selector creator" that uses lodash.isequal instead of === -const createDeepEqualSelector = createSelectorCreator(defaultMemoize, isEqual) +const createDeepEqualSelector = createSelectorCreator(lruMemoize, isEqual) // use the new "selector creator" to create a selector const selectSum = createDeepEqualSelector( @@ -597,9 +597,9 @@ const result = structuredSelector({ a: 1, b: 2 }) // will produce { x: 1, y: 2 } Reselect comes with a selection of memoization functions, each uniquely designed to address different scenarios and performance requirements. By effectively leveraging these functions, you can significantly enhance the efficiency and responsiveness of your applications. - + -#### defaultMemoize(func, equalityCheckOrOptions = defaultEqualityCheck) +#### lruMemoize(func, equalityCheckOrOptions = referenceEqualityCheck) Description @@ -607,10 +607,10 @@ The standard memoize function used by [`createSelector`]. It has a default cache size of 1. This means it always recalculates when the value of an argument changes. However, this can be customized as needed with a specific max cache size (since 4.1.0). -It determines if an argument has changed by calling the `equalityCheck` function. As `defaultMemoize` is designed to be used with immutable data, the default `equalityCheck` function checks for changes using [reference equality][Reference Equality Check]: +It determines if an argument has changed by calling the `equalityCheck` function. As `lruMemoize` is designed to be used with immutable data, the default `equalityCheck` function checks for changes using [reference equality][Reference Equality Check]: ```ts -const defaultEqualityCheck = (previousValue: any, currentValue: any) => { +const referenceEqualityCheck = (previousValue: any, currentValue: any) => { return previousValue === currentValue } ``` @@ -622,7 +622,7 @@ const defaultEqualityCheck = (previousValue: any, currentValue: any) => { | `func` | The function to be memoized. | | `equalityCheckOrOptions` | Either an `equality check` function or an `options` object. | -Since 4.1.0, `defaultMemoize` also accepts an options object as its first argument instead of an `equalityCheck` function. The `options` object may contain: +Since 4.1.0, `lruMemoize` also accepts an options object as its first argument instead of an `equalityCheck` function. The `options` object may contain: ```ts type EqualityFn = (a: any, b: any) => boolean @@ -636,7 +636,7 @@ interface DefaultMemoizeOptions { | Name | Description | | :-------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `equalityCheck` | Used to compare the individual arguments of the provided calculation function.
**`Default`** = `defaultEqualityCheck` | +| `equalityCheck` | Used to compare the individual arguments of the provided calculation function.
**`Default`** = `referenceEqualityCheck` | | `resultEqualityCheck` | If provided, used to compare a newly generated output value against previous values in the cache. If a match is found, the old value is returned. This addresses the common todos.map(todo => todo.id) use case, where an update to another field in the original data causes a recalculation due to changed references, but the output is still effectively the same. | | `maxSize` | The cache size for the selector. If greater than 1, the selector will use an LRU cache internally.
**`Default`** = 1 | @@ -657,7 +657,7 @@ A memoized function with a `.clearCache()` method attached.
Examples -###### Using `defaultMemoize` with [`createSelector`] +###### Using `lruMemoize` with [`createSelector`] ```ts import { shallowEqual } from 'react-redux' @@ -681,20 +681,20 @@ const selectTodoIds = createSelector( ) ``` -###### Using `defaultMemoize` with [`createSelectorCreator`] +###### Using `lruMemoize` with [`createSelectorCreator`] ```ts import { shallowEqual } from 'react-redux' -import { createSelectorCreator, defaultMemoize } from 'reselect' +import { createSelectorCreator, lruMemoize } from 'reselect' const createSelectorShallowEqual = createSelectorCreator({ - memoize: defaultMemoize, + memoize: lruMemoize, memoizeOptions: { equalityCheck: shallowEqual, resultEqualityCheck: shallowEqual, maxSize: 10 }, - argsMemoize: defaultMemoize, + argsMemoize: lruMemoize, argsMemoizeOptions: { equalityCheck: shallowEqual, resultEqualityCheck: shallowEqual, @@ -720,7 +720,7 @@ const selectTodoIds = createSelectorShallowEqual( Description -[`defaultMemoize`] has to be explicitly configured to have a cache size larger than 1, and uses an LRU cache internally. +[`lruMemoize`] has to be explicitly configured to have a cache size larger than 1, and uses an LRU cache internally. `weakMapMemoize` creates a tree of [`WeakMap`]-based cache nodes based on the identity of the arguments it's been called with (in this case, the extracted values from your input selectors). **This allows `weakMapMemoize` to have an effectively infinite cache size**. Cache results will be kept in memory as long as references to the arguments still exist, and then cleared out as the arguments are garbage-collected. @@ -770,7 +770,7 @@ selectItemsByCategory(state, 'Electronics') // Selector runs again! Before you could solve this in a number of different ways: -1. Set the `maxSize` with [`defaultMemoize`]: +1. Set the `maxSize` with [`lruMemoize`]: ```ts const selectItemsByCategory = createSelector( @@ -965,7 +965,7 @@ selectItemsByCategory(state, 'Electronics') Description -Uses an "auto-tracking" approach inspired by the work of the Ember Glimmer team. It uses a Proxy to wrap arguments and track accesses to nested fields in your selector on first read. Later, when the selector is called with new arguments, it identifies which accessed fields have changed and only recalculates the result if one or more of those accessed fields have changed. This allows it to be more precise than the shallow equality checks in `defaultMemoize`. +Uses an "auto-tracking" approach inspired by the work of the Ember Glimmer team. It uses a Proxy to wrap arguments and track accesses to nested fields in your selector on first read. Later, when the selector is called with new arguments, it identifies which accessed fields have changed and only recalculates the result if one or more of those accessed fields have changed. This allows it to be more precise than the shallow equality checks in `lruMemoize`. > [!WARNING] > This API is still experimental and undergoing testing. @@ -974,12 +974,12 @@ Uses an "auto-tracking" approach inspired by the work of the Ember Glimmer team. - Pros: - - It is likely to avoid excess calculations and recalculate fewer times than `defaultMemoize` will, which may also result in fewer component re-renders. + - It is likely to avoid excess calculations and recalculate fewer times than `lruMemoize` will, which may also result in fewer component re-renders. - Cons: - It only has a cache size of 1. - - It is slower than `defaultMemoize`, because it has to do more work. (How much slower is dependent on the number of accessed fields in a selector, number of calls, frequency of input changes, etc) + - It is slower than `lruMemoize`, because it has to do more work. (How much slower is dependent on the number of accessed fields in a selector, number of calls, frequency of input changes, etc) - It can have some unexpected behavior. Because it tracks nested field accesses, cases where you don't access a field will not recalculate properly. For example, a badly-written selector like: ```ts @@ -1533,7 +1533,7 @@ const selectItemById = createSelector( ### Can the memoization behavior be customized? -Yes. The built-in `defaultMemoize` memoizer works great for a lot of use cases, but it can be customized or swapped out for a different memoizer. See [these examples](#customize-equalitycheck-for-defaultmemoize). +Yes. The built-in `lruMemoize` memoizer works great for a lot of use cases, but it can be customized or swapped out for a different memoizer. See [these examples](#customize-equalitycheck-for-lrumemoize). ### How do I test a selector? @@ -1607,7 +1607,7 @@ test('selector unit test', () => { Yes, although if they pass in different arguments, you will need to handle that in order for memoization to work consistently: -- Pass a larger `maxSize` if using `defaultMemoize` ( as of 4.1.0+) +- Pass a larger `maxSize` if using `lruMemoize` ( as of 4.1.0+) - Use [`weakMapMemoize`](#weakmapmemoize) (as of 5.0.0+) ### Are there TypeScript Typings? @@ -1666,14 +1666,14 @@ const selectTodoByIdCurried = currySelector( Or for reusability you can do this: ```ts -import type { defaultMemoize, SelectorArray, UnknownMemoizer } from 'reselect' +import type { lruMemoize, SelectorArray, UnknownMemoizer } from 'reselect' import { createSelector } from 'reselect' export const createCurriedSelector = < InputSelectors extends SelectorArray, Result, - OverrideMemoizeFunction extends UnknownMemoizer = typeof defaultMemoize, - OverrideArgsMemoizeFunction extends UnknownMemoizer = typeof defaultMemoize + OverrideMemoizeFunction extends UnknownMemoizer = typeof lruMemoize, + OverrideArgsMemoizeFunction extends UnknownMemoizer = typeof lruMemoize >( ...args: Parameters< typeof createSelector< @@ -1777,8 +1777,8 @@ interface RootState { export type TypedCreateSelector< State, - MemoizeFunction extends UnknownMemoizer = typeof defaultMemoize, - ArgsMemoizeFunction extends UnknownMemoizer = typeof defaultMemoize + MemoizeFunction extends UnknownMemoizer = typeof lruMemoize, + ArgsMemoizeFunction extends UnknownMemoizer = typeof lruMemoize > = < InputSelectors extends readonly Selector[], Result, @@ -1911,7 +1911,7 @@ Originally inspired by getters in [NuclearJS](https://github.com/optimizely/nucl [output selector fields]: #output-selector-fields 'Output Selector Fields' [`createSelector`]: #createselectorinputselectors--inputselectors-resultfunc-createselectoroptions 'createSelector' [`createSelectorCreator`]: #createselectorcreatormemoize--options-memoizeoptions 'createSelectorCreator' -[`defaultMemoize`]: #defaultmemoizefunc-equalitycheckoroptions--defaultequalitycheck 'defaultMemoize' +[`lruMemoize`]: #lrumemoizefunc-equalitycheckoroptions--defaultequalitycheck 'lruMemoize' [`weakMapMemoize`]: #weakmapmemoizefunc---since-500 'weakMapMemoize' [`unstable_autotrackMemoize`]: #unstable_autotrackmemoizefunc---since-500 'unstable_autotrackMemoize' [`createStructuredSelector`]: #createstructuredselector-inputSelectorsObject--selectorcreator--createselector 'createStructuredSelector' diff --git a/src/autotrackMemoize/autotrackMemoize.ts b/src/autotrackMemoize/autotrackMemoize.ts index 82605e35b..1672cc571 100644 --- a/src/autotrackMemoize/autotrackMemoize.ts +++ b/src/autotrackMemoize/autotrackMemoize.ts @@ -14,15 +14,15 @@ import { createCache } from './autotracking' * in your selector on first read. Later, when the selector is called with * new arguments, it identifies which accessed fields have changed and * only recalculates the result if one or more of those accessed fields have changed. - * This allows it to be more precise than the shallow equality checks in `defaultMemoize`. + * This allows it to be more precise than the shallow equality checks in `lruMemoize`. * * __Design Tradeoffs for `autotrackMemoize`:__ * - Pros: - * - It is likely to avoid excess calculations and recalculate fewer times than `defaultMemoize` will, + * - It is likely to avoid excess calculations and recalculate fewer times than `lruMemoize` will, * which may also result in fewer component re-renders. * - Cons: * - It only has a cache size of 1. - * - It is slower than `defaultMemoize`, because it has to do more work. (How much slower is dependent on the number of accessed fields in a selector, number of calls, frequency of input changes, etc) + * - It is slower than `lruMemoize`, because it has to do more work. (How much slower is dependent on the number of accessed fields in a selector, number of calls, frequency of input changes, etc) * - It can have some unexpected behavior. Because it tracks nested field accesses, * cases where you don't access a field will not recalculate properly. * For example, a badly-written selector like: diff --git a/src/createSelectorCreator.ts b/src/createSelectorCreator.ts index 92553655a..671393590 100644 --- a/src/createSelectorCreator.ts +++ b/src/createSelectorCreator.ts @@ -27,8 +27,8 @@ import { /** * An instance of `createSelector`, customized with a given memoize implementation. * - * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). - * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. + * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). + * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. * * @public */ @@ -144,7 +144,7 @@ export interface CreateSelectorFunction< /** * Creates a selector creator function with the specified memoization function and options for customizing memoization behavior. * - * @param options - An options object containing the `memoize` function responsible for memoizing the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). It also provides additional options for customizing memoization. While the `memoize` property is mandatory, the rest are optional. + * @param options - An options object containing the `memoize` function responsible for memoizing the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). It also provides additional options for customizing memoization. While the `memoize` property is mandatory, the rest are optional. * @returns A customized `createSelector` function. * * @example @@ -166,8 +166,8 @@ export interface CreateSelectorFunction< * ) * ``` * - * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). - * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. + * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). + * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. * * @see {@link https://github.com/reduxjs/reselect#createselectorcreatormemoize--options-memoizeoptions createSelectorCreator} * @@ -194,7 +194,7 @@ export function createSelectorCreator< /** * Creates a selector creator function with the specified memoization function and options for customizing memoization behavior. * - * @param memoize - The `memoize` function responsible for memoizing the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). + * @param memoize - The `memoize` function responsible for memoizing the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). * @param memoizeOptionsFromArgs - Optional configuration options for the memoization function. These options are then passed to the memoize function as the second argument onwards. * @returns A customized `createSelector` function. * @@ -212,7 +212,7 @@ export function createSelectorCreator< * ) * ``` * - * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). + * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). * * @see {@link https://github.com/reduxjs/reselect#createselectorcreatormemoize--options-memoizeoptions createSelectorCreator} * @@ -230,8 +230,8 @@ export function createSelectorCreator( * @param memoizeOptionsFromArgs - Optional configuration options for the memoization function. These options are then passed to the memoize function as the second argument onwards. * @returns A customized `createSelector` function. * - * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). - * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. + * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). + * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. * @template MemoizeOrOptions - The type of the first argument. It can either be a `memoize` function or an `options` object containing the `memoize` function. */ export function createSelectorCreator< diff --git a/src/types.ts b/src/types.ts index 6ead83c92..5eacacc83 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,8 +54,8 @@ export type SelectorResultArray = /** * The options object used inside `createSelector` and `createSelectorCreator`. * - * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). - * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. + * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). + * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. * @template OverrideMemoizeFunction - The type of the optional `memoize` function that could be passed into the options object inside `createSelector` to override the original `memoize` function that was initially passed into `createSelectorCreator`. * @template OverrideArgsMemoizeFunction - The type of the optional `argsMemoize` function that could be passed into the options object inside `createSelector` to override the original `argsMemoize` function that was initially passed into `createSelectorCreator`. If none was initially provided, `weakMapMemoize` will be used. * @@ -80,7 +80,7 @@ export interface CreateSelectorOptions< /** * The memoize function that is used to memoize the {@linkcode OutputSelectorFields.resultFunc resultFunc} - * inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). + * inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). * * When passed directly into `createSelector`, it overrides the `memoize` function initially passed into `createSelectorCreator`. * @@ -105,7 +105,7 @@ export interface CreateSelectorOptions< /** * The optional memoize function that is used to memoize the arguments * passed into the output selector generated by `createSelector` - * (e.g., `defaultMemoize` or `weakMapMemoize`). + * (e.g., `lruMemoize` or `weakMapMemoize`). * * When passed directly into `createSelector`, it overrides the * `argsMemoize` function initially passed into `createSelectorCreator`. @@ -170,8 +170,8 @@ export interface CreateSelectorOptions< * * @template InputSelectors - The type of the input selectors. * @template Result - The type of the result returned by the `resultFunc`. - * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). - * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. + * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). + * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. * * @public */ @@ -244,8 +244,8 @@ export type OutputSelectorFields< * * @template InputSelectors - The type of the input selectors. * @template Result - The type of the result returned by the `resultFunc`. - * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). - * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `defaultMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. + * @template MemoizeFunction - The type of the memoize function that is used to memoize the `resultFunc` inside `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). + * @template ArgsMemoizeFunction - The type of the optional memoize function that is used to memoize the arguments passed into the output selector generated by `createSelector` (e.g., `lruMemoize` or `weakMapMemoize`). If none is explicitly provided, `weakMapMemoize` will be used. * * @public */ @@ -442,7 +442,7 @@ export type ExtractMemoizerFields = /** * Represents the additional properties attached to a function memoized by `reselect`. * - * `defaultMemoize`, `weakMapMemoize` and `autotrackMemoize` all return these properties. + * `lruMemoize`, `weakMapMemoize` and `autotrackMemoize` all return these properties. * * @see {@linkcode ExtractMemoizerFields ExtractMemoizerFields} * diff --git a/src/weakMapMemoize.ts b/src/weakMapMemoize.ts index 564fb9d56..39ab9c63e 100644 --- a/src/weakMapMemoize.ts +++ b/src/weakMapMemoize.ts @@ -99,7 +99,7 @@ export interface WeakMapMemoizeOptions { * - Cons: * - There's currently no way to alter the argument comparisons. * They're based on strict reference equality. - * - It's roughly the same speed as `defaultMemoize`, although likely a fraction slower. + * - It's roughly the same speed as `lruMemoize`, although likely a fraction slower. * * __Use Cases for `weakMapMemoize`:__ * - This memoizer is likely best used for cases where you need to call the diff --git a/test/benchmarks/weakMapMemoize.bench.ts b/test/benchmarks/weakMapMemoize.bench.ts index dd4d5e262..e8dd07fe1 100644 --- a/test/benchmarks/weakMapMemoize.bench.ts +++ b/test/benchmarks/weakMapMemoize.bench.ts @@ -208,7 +208,7 @@ describe('Parametric selectors: weakMapMemoize vs others', () => { ) }) -// describe('weakMapMemoize vs defaultMemoize with maxSize', () => { +// describe('weakMapMemoize vs lruMemoize with maxSize', () => { // const store = setupStore() // const state = store.getState() // const arrayOfNumbers = Array.from({ length: 30 }, (num, index) => index) diff --git a/test/defaultMemoize.spec.ts b/test/defaultMemoize.spec.ts index c603ea051..cf04e8cc1 100644 --- a/test/defaultMemoize.spec.ts +++ b/test/defaultMemoize.spec.ts @@ -8,7 +8,7 @@ const createSelector = createSelectorCreator({ argsMemoize: lruMemoize }) -describe('defaultMemoize', () => { +describe(lruMemoize, () => { test('Basic memoization', () => { let called = 0 const memoized = lruMemoize(state => { @@ -75,7 +75,7 @@ describe('defaultMemoize', () => { const anotherObject = { foo: 'bar' } const memoized = lruMemoize(a => a, shallowEqual) - // the first call to `memoized` doesn't hit because `defaultMemoize.lastArgs` is uninitialized + // the first call to `memoized` doesn't hit because `lruMemoize.lastArgs` is uninitialized // and so `equalityCheck` is never called memoized(someObject) // first call does not shallow compare @@ -91,7 +91,7 @@ describe('defaultMemoize', () => { This test was useful when we had a cache size of 1 previously, and always saved `lastArgs`. But, with the new implementation, this doesn't make sense any more. - // the third call does not fall through because `defaultMemoize` passes `anotherObject` as + // the third call does not fall through because `lruMemoize` passes `anotherObject` as // both the `newVal` and `oldVal` params. This allows `shallowEqual` to be much more performant // than if it had passed `someObject` as `oldVal`, even though `someObject` and `anotherObject` // are shallowly equal diff --git a/test/reselect.spec.ts b/test/reselect.spec.ts index 1f63cac86..36c8500b4 100644 --- a/test/reselect.spec.ts +++ b/test/reselect.spec.ts @@ -730,7 +730,7 @@ describe('argsMemoize and memoize', () => { ).toBe(2) selectorDefaultParametricArgsWeakMap(store.getState(), 2) // If we call the selector with 1, then 2, then 1 and back to 2 again, - // `defaultMemoize` will recompute a total of 4 times, + // `lruMemoize` will recompute a total of 4 times, // but weakMapMemoize will recompute only twice. expect(selectorDefaultParametricArgsWeakMap.recomputations()).toBe(2) expect( diff --git a/test/testUtils.ts b/test/testUtils.ts index 530484f44..1b8a2e6b8 100644 --- a/test/testUtils.ts +++ b/test/testUtils.ts @@ -1,6 +1,7 @@ import type { PayloadAction } from '@reduxjs/toolkit' import { combineReducers, configureStore, createSlice } from '@reduxjs/toolkit' import { test } from 'vitest' +import type { lruMemoize } from '../src/defaultMemoize' import type { AnyFunction, OutputSelector, Simplify } from '../src/types' export interface Todo { @@ -489,7 +490,7 @@ export const logRecomputations = (selector: S) => { } export const logSelectorRecomputations = < - S extends OutputSelector + S extends OutputSelector >( selector: S ) => { diff --git a/type-tests/argsMemoize.test-d.ts b/type-tests/argsMemoize.test-d.ts index b95bcbcf1..33e7678b4 100644 --- a/type-tests/argsMemoize.test-d.ts +++ b/type-tests/argsMemoize.test-d.ts @@ -4,7 +4,7 @@ import { unstable_autotrackMemoize as autotrackMemoize, createSelector, createSelectorCreator, - defaultMemoize, + lruMemoize, weakMapMemoize } from 'reselect' import { assertType, describe, expectTypeOf, test } from 'vitest' @@ -28,22 +28,22 @@ describe('memoize and argsMemoize', () => { const selectorDefaultSeparateInlineArgs = createSelector( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { memoize: defaultMemoize } + { memoize: lruMemoize } ) const selectorDefaultArgsAsArray = createSelector( [(state: RootState) => state.todos], todos => todos.map(t => t.id), - { memoize: defaultMemoize } + { memoize: lruMemoize } ) const selectorDefaultArgsAsArrayWithMemoizeOptions = createSelector( [(state: RootState) => state.todos], todos => todos.map(t => t.id), - { memoize: defaultMemoize, memoizeOptions: { maxSize: 2 } } + { memoize: lruMemoize, memoizeOptions: { maxSize: 2 } } ) const selectorDefaultSeparateInlineArgsWithMemoizeOptions = createSelector( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { memoize: defaultMemoize, memoizeOptions: { maxSize: 2 } } + { memoize: lruMemoize, memoizeOptions: { maxSize: 2 } } ) const selectorAutotrackSeparateInlineArgs = createSelector( (state: RootState) => state.todos, @@ -94,7 +94,7 @@ describe('memoize and argsMemoize', () => { todos => todos.map(t => t.id), { memoize: weakMapMemoize, memoizeOptions: { maxSize: 2 } } ) - const createSelectorDefault = createSelectorCreator(defaultMemoize) + const createSelectorDefault = createSelectorCreator(lruMemoize) const createSelectorWeakMap = createSelectorCreator(weakMapMemoize) const createSelectorAutotrack = createSelectorCreator(autotrackMemoize) const changeMemoizeMethodSelectorDefault = createSelectorDefault( @@ -105,15 +105,15 @@ describe('memoize and argsMemoize', () => { const changeMemoizeMethodSelectorWeakMap = createSelectorWeakMap( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { memoize: defaultMemoize } + { memoize: lruMemoize } ) const changeMemoizeMethodSelectorAutotrack = createSelectorAutotrack( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { memoize: defaultMemoize } + { memoize: lruMemoize } ) const changeMemoizeMethodSelectorDefaultWithMemoizeOptions = - // @ts-expect-error When memoize is changed to weakMapMemoize or autotrackMemoize, memoizeOptions cannot be the same type as options args in defaultMemoize. + // @ts-expect-error When memoize is changed to weakMapMemoize or autotrackMemoize, memoizeOptions cannot be the same type as options args in lruMemoize. createSelectorDefault( (state: RootState) => state.todos, // @ts-expect-error @@ -124,13 +124,13 @@ describe('memoize and argsMemoize', () => { createSelectorWeakMap( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { memoize: defaultMemoize, memoizeOptions: { maxSize: 2 } } // When memoize is changed to defaultMemoize, memoizeOptions can now be the same type as options args in defaultMemoize. + { memoize: lruMemoize, memoizeOptions: { maxSize: 2 } } // When memoize is changed to lruMemoize, memoizeOptions can now be the same type as options args in lruMemoize. ) const changeMemoizeMethodSelectorAutotrackWithMemoizeOptions = createSelectorAutotrack( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { memoize: defaultMemoize, memoizeOptions: { maxSize: 2 } } // When memoize is changed to defaultMemoize, memoizeOptions can now be the same type as options args in defaultMemoize. + { memoize: lruMemoize, memoizeOptions: { maxSize: 2 } } // When memoize is changed to lruMemoize, memoizeOptions can now be the same type as options args in lruMemoize. ) }) @@ -138,22 +138,22 @@ describe('memoize and argsMemoize', () => { const selectorDefaultSeparateInlineArgs = createSelector( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize } + { argsMemoize: lruMemoize } ) const selectorDefaultArgsAsArray = createSelector( [(state: RootState) => state.todos], todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize } + { argsMemoize: lruMemoize } ) const selectorDefaultArgsAsArrayWithMemoizeOptions = createSelector( [(state: RootState) => state.todos], todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize, argsMemoizeOptions: { maxSize: 2 } } + { argsMemoize: lruMemoize, argsMemoizeOptions: { maxSize: 2 } } ) const selectorDefaultSeparateInlineArgsWithMemoizeOptions = createSelector( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize, argsMemoizeOptions: { maxSize: 2 } } + { argsMemoize: lruMemoize, argsMemoizeOptions: { maxSize: 2 } } ) const selectorAutotrackSeparateInlineArgs = createSelector( (state: RootState) => state.todos, @@ -228,7 +228,7 @@ describe('memoize and argsMemoize', () => { // @ts-expect-error todos => todos.map(t => t.id), { - memoize: defaultMemoize, + memoize: lruMemoize, argsMemoize: weakMapMemoize, memoizeOptions: { equalityCheck: @@ -239,9 +239,9 @@ describe('memoize and argsMemoize', () => { argsMemoizeOptions: { maxSize: 2 } } ) - // const createSelectorDefaultMemoize = createSelectorCreator(defaultMemoize) + // const createSelectorDefaultMemoize = createSelectorCreator(lruMemoize) const createSelectorDefaultMemoize = createSelectorCreator({ - memoize: defaultMemoize + memoize: lruMemoize }) const selectorWeakMapSeparateInlineArgsWithMemoizeOptions3 = // @ts-expect-error When argsMemoize is weakMapMemoize, type of argsMemoizeOptions needs to be the same as options args in weakMapMemoize. @@ -250,7 +250,7 @@ describe('memoize and argsMemoize', () => { // @ts-expect-error todos => todos.map(t => t.id), { - memoize: defaultMemoize, + memoize: lruMemoize, argsMemoize: weakMapMemoize, // memoizeOptions: [], memoizeOptions: [ @@ -302,7 +302,7 @@ describe('memoize and argsMemoize', () => { // argsMemoizeOptions: (a, b) => a === b } ) - const createSelectorDefault = createSelectorCreator(defaultMemoize) + const createSelectorDefault = createSelectorCreator(lruMemoize) const createSelectorWeakMap = createSelectorCreator(weakMapMemoize) const createSelectorAutotrack = createSelectorCreator(autotrackMemoize) const changeMemoizeMethodSelectorDefault = createSelectorDefault( @@ -313,15 +313,15 @@ describe('memoize and argsMemoize', () => { const changeMemoizeMethodSelectorWeakMap = createSelectorWeakMap( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize } + { argsMemoize: lruMemoize } ) const changeMemoizeMethodSelectorAutotrack = createSelectorAutotrack( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize } + { argsMemoize: lruMemoize } ) const changeMemoizeMethodSelectorDefaultWithMemoizeOptions = - // @ts-expect-error When argsMemoize is changed to weakMapMemoize or autotrackMemoize, argsMemoizeOptions cannot be the same type as options args in defaultMemoize. + // @ts-expect-error When argsMemoize is changed to weakMapMemoize or autotrackMemoize, argsMemoizeOptions cannot be the same type as options args in lruMemoize. createSelectorDefault( (state: RootState) => state.todos, // @ts-expect-error @@ -332,13 +332,13 @@ describe('memoize and argsMemoize', () => { createSelectorWeakMap( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize, argsMemoizeOptions: { maxSize: 2 } } // When argsMemoize is changed to defaultMemoize, argsMemoizeOptions can now be the same type as options args in defaultMemoize. + { argsMemoize: lruMemoize, argsMemoizeOptions: { maxSize: 2 } } // When argsMemoize is changed to lruMemoize, argsMemoizeOptions can now be the same type as options args in lruMemoize. ) const changeMemoizeMethodSelectorAutotrackWithMemoizeOptions = createSelectorAutotrack( (state: RootState) => state.todos, todos => todos.map(t => t.id), - { argsMemoize: defaultMemoize, argsMemoizeOptions: { maxSize: 2 } } // When argsMemoize is changed to defaultMemoize, argsMemoizeOptions can now be the same type as options args in defaultMemoize. + { argsMemoize: lruMemoize, argsMemoizeOptions: { maxSize: 2 } } // When argsMemoize is changed to lruMemoize, argsMemoizeOptions can now be the same type as options args in lruMemoize. ) }) @@ -397,16 +397,16 @@ describe('memoize and argsMemoize', () => { // Checking to see if types dynamically change if memoize or argsMemoize are overridden inside `createSelector`. // `microMemoize` was initially passed into `createSelectorCreator` - // as `memoize` and `argsMemoize`, After overriding them both to `defaultMemoize`, + // as `memoize` and `argsMemoize`, After overriding them both to `lruMemoize`, // not only does the type for `memoizeOptions` and `argsMemoizeOptions` change to - // the options parameter of `defaultMemoize`, the output selector fields - // also change their type to the return type of `defaultMemoize`. + // the options parameter of `lruMemoize`, the output selector fields + // also change their type to the return type of `lruMemoize`. const selectorMicroMemoizeOverridden = createSelectorMicroMemoize( (state: RootState) => state.todos, todos => todos.map(t => t.id), { - memoize: defaultMemoize, - argsMemoize: defaultMemoize, + memoize: lruMemoize, + argsMemoize: lruMemoize, memoizeOptions: { equalityCheck: (a, b) => a === b, maxSize: 2 }, argsMemoizeOptions: { equalityCheck: (a, b) => a === b, maxSize: 3 } } @@ -462,8 +462,8 @@ describe('memoize and argsMemoize', () => { [(state: RootState) => state.todos], todos => todos.map(({ id }) => id), { - memoize: defaultMemoize, - argsMemoize: defaultMemoize, + memoize: lruMemoize, + argsMemoize: lruMemoize, memoizeOptions: { equalityCheck: (a, b) => a === b, maxSize: 2 }, argsMemoizeOptions: { equalityCheck: (a, b) => a === b, maxSize: 3 } } @@ -522,7 +522,7 @@ describe('memoize and argsMemoize', () => { (state: RootState) => state.todos, todos => todos.map(({ id }) => id), { - argsMemoize: defaultMemoize, + argsMemoize: lruMemoize, memoizeOptions: { isPromise: false, resultEqualityCheck: @@ -537,7 +537,7 @@ describe('memoize and argsMemoize', () => { (state: RootState) => state.todos, todos => todos.map(({ id }) => id), { - argsMemoize: defaultMemoize, + argsMemoize: lruMemoize, memoizeOptions: { isPromise: false }, argsMemoizeOptions: { resultEqualityCheck: (a, b) => a === b } } @@ -597,7 +597,7 @@ describe('memoize and argsMemoize', () => { (state: RootState) => state.todos, todos => todos.map(t => t.id), { - memoize: defaultMemoize, + memoize: lruMemoize, memoizeOptions: { resultEqualityCheck: (a, b) => a === b } } ) @@ -653,32 +653,32 @@ describe('memoize and argsMemoize', () => { ) const selectorMicroMemoizePartiallyOverridden = - // @ts-expect-error Since `argsMemoize` is set to `defaultMemoize`, `argsMemoizeOptions` must match the options object parameter of `defaultMemoize` + // @ts-expect-error Since `argsMemoize` is set to `lruMemoize`, `argsMemoizeOptions` must match the options object parameter of `lruMemoize` createSelectorMicroMemoize( (state: RootState) => state.todos, // @ts-expect-error todos => todos.map(t => t.id), { - memoize: defaultMemoize, - argsMemoize: defaultMemoize, + memoize: lruMemoize, + argsMemoize: lruMemoize, memoizeOptions: { equalityCheck: // @ts-expect-error (a, b) => a === b, maxSize: 2 }, - argsMemoizeOptions: { isPromise: false } // This field causes a type error since it does not match the options param of `defaultMemoize`. + argsMemoizeOptions: { isPromise: false } // This field causes a type error since it does not match the options param of `lruMemoize`. } ) const selectorMicroMemoizePartiallyOverridden1 = - // @ts-expect-error Since `argsMemoize` is set to `defaultMemoize`, `argsMemoizeOptions` must match the options object parameter of `defaultMemoize` + // @ts-expect-error Since `argsMemoize` is set to `lruMemoize`, `argsMemoizeOptions` must match the options object parameter of `lruMemoize` createSelectorMicroMemoize( (state: RootState) => state.todos, // @ts-expect-error todos => todos.map(t => t.id), { - memoize: defaultMemoize, - argsMemoize: defaultMemoize, + memoize: lruMemoize, + argsMemoize: lruMemoize, memoizeOptions: [ { equalityCheck: @@ -687,7 +687,7 @@ describe('memoize and argsMemoize', () => { maxSize: 2 } ], - argsMemoizeOptions: [{ isPromise: false }] // This field causes a type error since it does not match the options param of `defaultMemoize`. + argsMemoizeOptions: [{ isPromise: false }] // This field causes a type error since it does not match the options param of `lruMemoize`. } ) const selectorMicroMemoizePartiallyOverridden2 = createSelectorMicroMemoize( @@ -784,7 +784,7 @@ describe('memoize and argsMemoize', () => { test('memoize And argsMemoize In createSelectorCreator', () => { // If we don't pass in `argsMemoize`, the type for `argsMemoizeOptions` - // falls back to the options parameter of `defaultMemoize`. + // falls back to the options parameter of `lruMemoize`. const createSelectorArgsMemoizeOptionsFallbackToDefault = createSelectorCreator({ memoize: microMemoize, @@ -857,7 +857,7 @@ describe('memoize and argsMemoize', () => { ).toEqualTypeOf(weakMapMemoize) const createSelectorWithWrongArgsMemoizeOptions = - // @ts-expect-error If we don't pass in `argsMemoize`, the type for `argsMemoizeOptions` falls back to the options parameter of `defaultMemoize`. + // @ts-expect-error If we don't pass in `argsMemoize`, the type for `argsMemoizeOptions` falls back to the options parameter of `lruMemoize`. createSelectorCreator({ memoize: microMemoize, memoizeOptions: { isEqual: (a, b) => a === b }, diff --git a/type-tests/createSelectorCreator.test-d.ts b/type-tests/createSelectorCreator.test-d.ts index da5897277..e91205f19 100644 --- a/type-tests/createSelectorCreator.test-d.ts +++ b/type-tests/createSelectorCreator.test-d.ts @@ -3,7 +3,7 @@ import memoizeOne from 'memoize-one' import microMemoize from 'micro-memoize' import { createSelectorCreator, - defaultMemoize, + lruMemoize, unstable_autotrackMemoize as autotrackMemoize, weakMapMemoize } from 'reselect' @@ -28,7 +28,7 @@ const state: RootState = { describe('createSelectorCreator', () => { test('options object as argument', () => { const createSelectorDefault = createSelectorCreator({ - memoize: defaultMemoize + memoize: lruMemoize }) const createSelectorWeakMap = createSelectorCreator({ memoize: weakMapMemoize @@ -48,7 +48,7 @@ describe('createSelectorCreator', () => { }) test('memoize function as argument', () => { - const createSelectorDefault = createSelectorCreator(defaultMemoize) + const createSelectorDefault = createSelectorCreator(lruMemoize) const createSelectorWeakMap = createSelectorCreator(weakMapMemoize) const createSelectorAutotrack = createSelectorCreator(autotrackMemoize) const createSelectorMicro = createSelectorCreator(microMemoize) diff --git a/type-tests/deepNesting.test-d.ts b/type-tests/deepNesting.test-d.ts index 5a5e69bc2..e602026f1 100644 --- a/type-tests/deepNesting.test-d.ts +++ b/type-tests/deepNesting.test-d.ts @@ -1,5 +1,5 @@ import microMemoize from 'micro-memoize' -import { createSelector, defaultMemoize } from 'reselect' +import { createSelector, lruMemoize } from 'reselect' import { describe, test } from 'vitest' interface RootState { @@ -75,91 +75,91 @@ describe('deep nesting', () => { const selector0 = createSelector(readOne, one => one) const selector1 = createSelector(selector0, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector2 = createSelector(selector1, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector3 = createSelector(selector2, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector4 = createSelector(selector3, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector5 = createSelector(selector4, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector6 = createSelector(selector5, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector7 = createSelector(selector6, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector8 = createSelector(selector7, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector9 = createSelector(selector8, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector10 = createSelector(selector9, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector11 = createSelector(selector10, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector12 = createSelector(selector11, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector13 = createSelector(selector12, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector14 = createSelector(selector13, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector15 = createSelector(selector14, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector16 = createSelector(selector15, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector17 = createSelector(selector16, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector18 = createSelector(selector17, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector19 = createSelector(selector18, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector20 = createSelector(selector19, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector21 = createSelector(selector20, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector22 = createSelector(selector21, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector23 = createSelector(selector22, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector24 = createSelector(selector23, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector25 = createSelector(selector24, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector26 = createSelector(selector25, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector27 = createSelector(selector26, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector28 = createSelector(selector27, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) const selector29 = createSelector(selector28, s => s, { - memoize: defaultMemoize + memoize: lruMemoize }) })