knowledgebase_law/node_modules/reselect/dist/reselect.mjs.map

1 line
94 KiB
Plaintext
Raw Normal View History

2025-04-11 23:47:09 +08:00
{"version":3,"sources":["../src/devModeChecks/identityFunctionCheck.ts","../src/devModeChecks/inputStabilityCheck.ts","../src/devModeChecks/setGlobalDevModeChecks.ts","../src/utils.ts","../src/autotrackMemoize/autotracking.ts","../src/autotrackMemoize/tracking.ts","../src/autotrackMemoize/proxy.ts","../src/lruMemoize.ts","../src/autotrackMemoize/autotrackMemoize.ts","../src/weakMapMemoize.ts","../src/createSelectorCreator.ts","../src/createStructuredSelector.ts"],"sourcesContent":["import type { AnyFunction } from '../types'\r\n\r\n/**\r\n * Runs a check to determine if the given result function behaves as an\r\n * identity function. An identity function is one that returns its\r\n * input unchanged, for example, `x => x`. This check helps ensure\r\n * efficient memoization and prevent unnecessary re-renders by encouraging\r\n * proper use of transformation logic in result functions and\r\n * extraction logic in input selectors.\r\n *\r\n * @param resultFunc - The result function to be checked.\r\n * @param inputSelectorsResults - The results of the input selectors.\r\n * @param outputSelectorResult - The result of the output selector.\r\n *\r\n * @see {@link https://reselect.js.org/api/development-only-stability-checks#identityfunctioncheck `identityFunctionCheck`}\r\n *\r\n * @since 5.0.0\r\n * @internal\r\n */\r\nexport const runIdentityFunctionCheck = (\r\n resultFunc: AnyFunction,\r\n inputSelectorsResults: unknown[],\r\n outputSelectorResult: unknown\r\n) => {\r\n if (\r\n inputSelectorsResults.length === 1 &&\r\n inputSelectorsResults[0] === outputSelectorResult\r\n ) {\r\n let isInputSameAsOutput = false\r\n try {\r\n const emptyObject = {}\r\n if (resultFunc(emptyObject) === emptyObject) isInputSameAsOutput = true\r\n } catch {\r\n // Do nothing\r\n }\r\n if (isInputSameAsOutput) {\r\n let stack: string | undefined = undefined\r\n try {\r\n throw new Error()\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/no-extra-semi, no-extra-semi\r\n ;({ stack } = e as Error)\r\n }\r\n console.warn(\r\n 'The result function returned its own inputs without modification. e.g' +\r\n '\\n`createSelector([state => state.todos], todos => todos)`' +\r\n '\\nThis could lead to inefficient memoization and unnecessary re-renders.' +\r\n '\\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.',\r\n { stack }\r\n )\r\n }\r\n }\r\n}\r\n","import type { CreateSelectorOptions, UnknownMemoizer } from '../types'\r\n\r\n/**\r\n * Runs a stability check to ensure the input selector results remain stable\r\n * when provided with the same arguments. This function is designed to detect\r\n * changes in the output of input selectors, which can impact the performance of memoized selectors.\r\n *\r\n * @param inputSelectorResultsObject - An object containing two arrays: `inputSelectorResults` and `inputSelectorResultsCopy`, representing the results of input selectors.\r\n * @param options - Options object consisting of a `memoize` function and a `memoizeOptions` object.\r\n * @param inputSelectorArgs - List of arguments being passed to the input selectors.\r\n *\r\n * @see {@link https://reselect.js.org/api/development-only-stability-checks/#inputstabilitycheck `inputStabilityCheck`}\r\n *\r\n * @since 5.0.0\r\n * @internal\r\n */\r\nexport const runInputStabilityCheck = (\r\n inputSelectorResultsObject: {\r\n inputSelectorResults: unknown[]\r\n inputSelectorResultsCopy: unknown[]\r\n },\r\n options: Required<\r\n Pick<\r\n CreateSelectorOptions<UnknownMemoizer, UnknownMemoizer>,\r\n 'memoize' | 'memoizeOptions'\r\n >\r\n >,\r\n inputSelectorArgs: unknown[] | IArguments\r\n) => {\r\n const { memoize, memoizeOptions } = options\r\n const { inputSelectorResults, inputSelectorResultsCopy } =\r\n inputSelectorResultsObject\r\n const createAnEmptyObject = memoize(() => ({}), ...memoizeOptions)\r\n // if the memoize