{"name":"reselect","version":"5.2.0","keywords":["react","redux"],"license":"MIT","_id":"reselect@5.2.0","maintainers":[{"name":"gaearon","email":"dan.abramov@gmail.com"},{"name":"timdorr","email":"timdorr@timdorr.com"},{"name":"ellbee","email":"l_bannard@yahoo.co.uk"},{"name":"phryneas","email":"mail@lenzw.de"},{"name":"acemarke","email":"mark.erikson@gmail.com"},{"name":"eskimojo","email":"ben.j.durrant@gmail.com"}],"contributors":[{"url":"https://github.com/ellbee","name":"Lee Bannard","email":"l_bannard@yahoo.co.uk"},{"url":"https://github.com/faassen","name":"Martijn Faassen"},{"url":"https://github.com/ianks","name":"Ian Ker-Seymer","email":"i.kerseymer@gmail.com"},{"url":"https://github.com/SpainTrain","name":"Mike S"},{"url":"https://github.com/omnidan","name":"Daniel Bugl","email":"me@omnidan.net"},{"url":"https://github.com/ryanatkn","name":"Ryan"},{"url":"https://github.com/HeyImAlex","name":"Alex Guerra","email":"alex@heyimalex.com"},{"url":"https://github.com/speedskater","name":"speedskater"},{"url":"https://github.com/sericaia","name":"Daniela Borges"},{"url":"https://github.com/existentialism","name":"Brian Ng","email":"bng412@gmail.com"},{"url":"https://github.com/chentsulin","name":"C. T. Lin","email":"chentsulin@gmail.com"},{"url":"https://github.com/chungchiehlun","name":"Jay","email":"wuceh14678@gmail.com"},{"url":"https://github.com/madebyherzblut","name":"Christian Schuhmann"},{"url":"https://github.com/volrath","name":"Daniel Barreto","email":"daniel.barreto.n@gmail.com"},{"url":"https://github.com/ifunk","name":"Adam Royle"},{"url":"https://github.com/elliotcm","name":"Elliot Crosby-McCullough","email":"elliot.cm@gmail.com"},{"url":"https://github.com/frankwallis","name":"frankwallis"},{"url":"https://github.com/kaddopur","name":"Jason Huang","email":"chaoju.huang@gmail.com"},{"url":"https://github.com/joshkel","name":"Josh Kelley"},{"url":"https://github.com/leonaves","name":"Leon Aves"},{"url":"https://github.com/markdalgleish","name":"Mark Dalgleish"},{"url":"https://github.com/chromakode","name":"Max Goodman","email":"c@chromako.de"},{"url":"https://github.com/weblancaster","name":"Michael Lancaster","email":"michaell.llancaster@gmail.com"},{"url":"https://github.com/zalmoxisus","name":"Mihail Diordiev"},{"url":"https://github.com/PSpSynedra","name":"PSpSynedra"},{"url":"https://github.com/SimenB","name":"Simen Bekkhus","email":"sbekkhus91@gmail.com"},{"url":"https://github.com/WadePeterson","name":"Wade Peterson"},{"url":"https://github.com/ambar","name":"长天之云","email":"ambar.lee@gmail.com"},{"url":"https://github.com/courthead","name":"Courtland Allen","email":"csallen@alum.mit.edu"},{"url":"https://github.com/HenrikJoreteg","name":"Henrik Joreteg","email":"henrik@joreteg.com"},{"url":"https://github.com/kyldvs","name":"Kyle Davis"},{"url":"https://github.com/clickclickonsal","name":"Salvador Hernandez","email":"s.hernandez5400@gmail.com"},{"url":"https://github.com/npbee","name":"Nick Ball"},{"url":"https://github.com/mctep","name":"mctep"},{"url":"https://github.com/jacobrask","name":"Jacob Rask","email":"jacob@jacobrask.net"},{"url":"https://github.com/luqmaan","name":"Luqmaan Dawoodjee","email":"ldawoodjee@gmail.com"},{"url":"https://github.com/wbreakell","name":"Walter Breakell"},{"url":"https://github.com/matthetherington","name":"Matthew Hetherington"},{"url":"https://github.com/mjw56","name":"Mike Wilcox","email":"mwilcox56@gmail.com"},{"url":"https://github.com/threehams","name":"David Edmondson"},{"url":"https://github.com/zandroid","name":"Andrey Zaytsev","email":"za@zalab.net"},{"url":"https://github.com/1ven","name":"1ven"},{"url":"https://github.com/alexesdev","name":"Alexey Yurchenko","email":"alexes.dev@gmail.com"},{"url":"https://github.com/dpwrussell","name":"Douglas Russell"},{"url":"https://github.com/yoni-tock","name":"Yonatan Kogan"},{"url":"https://github.com/pesho","name":"Peter Petrov"},{"url":"https://github.com/wbreakell","name":"Walter Breakell"},{"url":"https://github.com/madeinfree","name":"Whien","email":"sal95610@gmail.com"},{"url":"https://github.com/bsideup","name":"Sergei Egorov","email":"bsideup@gmail.com"},{"url":"https://github.com/jimbolla","name":"Jim Bolla"},{"url":"https://github.com/carlbernrdo","name":"Carl Bernardo"},{"url":"https://github.com/aikoven","name":"Daniel Lytkin","email":"dan.lytkin@gmail.com"},{"url":"https://github.com/johnhaley81","name":"John Haley","email":"john@haley.io"},{"url":"https://github.com/alex3165","name":"Alexandre","email":"alexr.3165@gmail.com"}],"homepage":"https://github.com/reduxjs/reselect#readme","bugs":{"url":"https://github.com/reduxjs/reselect/issues"},"dist":{"shasum":"f380ef7664332d26ea06c1cba04bdbbdcaa955f1","tarball":"http://registry-npm.ywwl.com/reselect/download/reselect-5.2.0.tgz","fileCount":32,"integrity":"sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw==","signatures":[{"sig":"MEYCIQDEicwYgZlAhSWg7HaRrQrVPL0Pos+vHTVqLATUrIUW0AIhALFoBB+R6bFmJ4dDFB0ZdGl5AJlKHYU0R3Cqwi5Xdmcl","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/reselect@5.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":725387,"size":160165,"noattachment":false,"key":"/reselect/-/reselect-5.2.0.tgz"},"main":"./dist/cjs/index.js","types":"./dist/reselect.d.ts","module":"./dist/reselect.legacy-esm.js","authors":["Lee Bannard","Robert Binna","Martijn Faassen","Philip Spitzlinger"],"exports":{".":{"types":"./dist/reselect.d.ts","import":"./dist/reselect.mjs","default":"./dist/cjs/index.js"},"./package.json":"./package.json"},"gitHead":"65c48cdc919b955955e75f95d5b20e6ded69f2c7","scripts":{"lint":"eslint src test","test":"node --expose-gc ./node_modules/vitest/dist/cli-wrapper.js --run && vitest --run --typecheck.only","bench":"vitest --run bench --mode production","build":"yarn clean && tsup","clean":"rimraf dist","format":"prettier --write \"{src,test}/**/*.{js,ts}\" \"docs/**/*.md\"","prepack":"yarn build","test:cov":"vitest run --coverage","docs:build":"yarn --cwd website build","docs:clear":"yarn --cwd website clear","docs:serve":"yarn --cwd website serve","docs:start":"yarn --cwd website start","test:watch":"node --expose-gc ./node_modules/vitest/dist/cli-wrapper.js --watch","type-check":"vitest --run --typecheck.only","test:typescript":"tsc --noEmit -p typescript_test/tsconfig.json","type-check:trace":"vitest --run --typecheck.only && tsc --noEmit -p typescript_test/tsconfig.json --generateTrace trace && npx @typescript/analyze-trace trace && rimraf trace"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:94e7f058-adc4-4c3a-b6e2-2946ed8f74dd"}},"repository":{"url":"git+https://github.com/reduxjs/reselect.git","type":"git"},"_npmVersion":"11.12.1","description":"Selectors for Redux.","directories":{},"resolutions":{"esbuild":"0.23.0"},"sideEffects":false,"_nodeVersion":"24.15.0","_hasShrinkwrap":false,"packageManager":"yarn@4.4.1","devDependencies":{"tsup":"^8.2.4","jsdom":"^23.0.0","react":"^18.2.0","eslint":"^8.0.1","lodash":"^4.17.21","rimraf":"^3.0.2","vitest":"^1.6.0","shelljs":"^0.8.5","prettier":"^2.7.1","react-dom":"^18.2.0","typescript":"^5.8.2","memoize-one":"^6.0.0","react-redux":"^9.0.4","@types/react":"^18.2.38","@types/lodash":"^4.14.175","micro-memoize":"^4.0.9","@types/shelljs":"^0.8.11","lodash.memoize":"^4.1.2","@reduxjs/toolkit":"^2.0.1","@types/react-dom":"^18.2.17","eslint-plugin-react":"^7.26.1","netlify-plugin-cache":"^1.0.3","@testing-library/react":"^14.1.2","eslint-plugin-typescript":"0.14.0","@typescript-eslint/parser":"^6","@typescript/analyze-trace":"^0.10.1","@typescript-eslint/eslint-plugin":"^6","@typescript-eslint/eslint-plugin-tslint":"^6"},"_npmOperationalInternal":{"tmp":"tmp/reselect_5.2.0_1778860301756_0.6116955873439989","host":"s3://npm-registry-packages-npm-production"},"readme":"# Reselect\n\n[![npm package][npm-badge]][npm][![Coveralls][coveralls-badge]][coveralls][![GitHub Workflow Status][build-badge]][build]![TypeScript][typescript-badge]\n\nA library for creating memoized \"selector\" functions. Commonly used with Redux, but usable with any plain JS immutable data as well.\n\n- Selectors can compute derived data, allowing [Redux] to store the minimal possible state.\n- Selectors are efficient. A selector is not recomputed unless one of its arguments changes.\n- Selectors are composable. They can be used as input to other selectors.\n\nThe **Redux docs usage page on [Deriving Data with Selectors](https://redux.js.org/usage/deriving-data-selectors)** covers the purpose and motivation for selectors, why memoized selectors are useful, typical Reselect usage patterns, and using selectors with [React-Redux].\n\n## Installation\n\n### Redux Toolkit\n\nWhile Reselect is not exclusive to [Redux], it is already included by default in [the official Redux Toolkit package](https://redux-toolkit.js.org) - no further installation needed.\n\n```ts\nimport { createSelector } from '@reduxjs/toolkit'\n```\n\n### Standalone\n\nFor standalone usage, install the `reselect` package:\n\n```bash\n# NPM\nnpm install reselect\n\n# Yarn\nyarn add reselect\n```\n\n---\n\n## Documentation\n\nThe Reselect docs are available at **https://reselect.js.org**, and include usage guides and API references:\n\n- [**Introduction**](https://reselect.js.org/introduction/getting-started)\n- [**How Does Reselect Work?**](https://reselect.js.org/introduction/how-does-reselect-work)\n- **API Reference**:\n  - **[`createSelector`]**\n  - **[`createSelectorCreator`]**\n  - **[`createStructuredSelector`]**\n  - [**Development-Only Checks**](https://reselect.js.org/api/development-only-checks)\n  - **[`lruMemoize`]**\n  - **[`weakMapMemoize`]**\n- [**FAQ**](https://reselect.js.org/FAQ)\n\n## Basic Usage\n\nReselect exports a [`createSelector`] API, which generates memoized selector functions. [`createSelector`] accepts one or more [input selectors], which extract values from arguments, and a [result function] function that receives the extracted values and should return a derived value. If the generated [output selector] is called multiple times, the output will only be recalculated when the extracted values have changed.\n\nYou can play around with the following **example** in [this CodeSandbox](https://codesandbox.io/s/reselect-example-g3k9gf?file=/src/index.js):\n\n```ts\nimport { createSelector } from 'reselect'\n\ninterface RootState {\n  todos: { id: number; completed: boolean }[]\n  alerts: { id: number; read: boolean }[]\n}\n\nconst state: RootState = {\n  todos: [\n    { id: 0, completed: false },\n    { id: 1, completed: true }\n  ],\n  alerts: [\n    { id: 0, read: false },\n    { id: 1, read: true }\n  ]\n}\n\nconst selectCompletedTodos = (state: RootState) => {\n  console.log('selector ran')\n  return state.todos.filter(todo => todo.completed === true)\n}\n\nselectCompletedTodos(state) // selector ran\nselectCompletedTodos(state) // selector ran\nselectCompletedTodos(state) // selector ran\n\nconst memoizedSelectCompletedTodos = createSelector(\n  [(state: RootState) => state.todos],\n  todos => {\n    console.log('memoized selector ran')\n    return todos.filter(todo => todo.completed === true)\n  }\n)\n\nmemoizedSelectCompletedTodos(state) // memoized selector ran\nmemoizedSelectCompletedTodos(state)\nmemoizedSelectCompletedTodos(state)\n\nconsole.log(selectCompletedTodos(state) === selectCompletedTodos(state)) //=> false\n\nconsole.log(\n  memoizedSelectCompletedTodos(state) === memoizedSelectCompletedTodos(state)\n) //=> true\n```\n\nAs you can see from the example above, `memoizedSelectCompletedTodos` does not run the second or third time, but we still get the same return value as last time.\n\nIn addition to skipping unnecessary recalculations, `memoizedSelectCompletedTodos` returns the existing result reference if there is no recalculation. This is important for libraries like [React-Redux] or [React] that often rely on reference equality checks to optimize UI updates.\n\n---\n\n## Terminology\n\n- <a name=\"selector-function\"></a>[**Selector Function**](#selector-function): A function that accepts one or more JavaScript values as arguments, and derives a result. When used with [Redux], the first argument is typically the entire Redux store state.\n- <a name=\"input-selectors\"></a>[**input selectors**](#input-selectors): Basic selector functions used as building blocks for creating a memoized selector. They are passed as the first argument(s) to [`createSelector`], and are called with all selector arguments. They are responsible for extracting and providing necessary values to the [result function].\n- <a name=\"output-selector\"></a>[**Output Selector**](#output-selector): The actual memoized selectors created by [`createSelector`].\n- <a name=\"result-function\"></a>[**Result Function**](#result-function): The function that comes after the [input selectors]. It takes the [input selectors]' return values as arguments and returns a result.\n- <a name=\"dependencies\"></a>[**`Dependencies`**](#dependencies): Same as [input selectors]. They are what the [output selector] \"depends\" on.\n\nThe below example serves as a visual aid:\n\n```ts\nconst outputSelector = createSelector(\n  [inputSelector1, inputSelector2, inputSelector3], // synonymous with `dependencies`.\n  resultFunc // Result function\n)\n```\n\n---\n\n## What's New in 5.0.0?\n\nVersion 5.0.0 introduces several new features and improvements:\n\n- **Customization Enhancements**:\n\n  - Added the ability to pass an options object to [`createSelectorCreator`], allowing for customized `memoize` and `argsMemoize` functions, alongside their respective options (`memoizeOptions` and `argsMemoizeOptions`).\n  - The [`createSelector`] function now supports direct customization of `memoize` and `argsMemoize` within its options object.\n\n- **Memoization Functions**:\n\n  - Introduced a new default memoization function: `weakMapMemoize`\n  - Incorporated `memoize` and `argsMemoize` into the [output selector fields] for debugging purposes.\n\n- **TypeScript Support and Performance**:\n\n  - Discontinued support for TypeScript versions below 4.7, aligning with modern TypeScript features.\n  - Significantly improved TypeScript performance for nesting [output selectors][output selector]. The nesting limit has increased from approximately 8 to around 30 [output selectors][output selector], greatly reducing the occurrence of the infamous `Type instantiation is excessively deep and possibly infinite` error.\n\n- **Selector API Enhancements**:\n\n  - Removed the second overload of `createStructuredSelector` due to its susceptibility to runtime errors.\n\n- **Additional Functionalities**:\n\n  - Added `dependencyRecomputations` and `resetDependencyRecomputations` to the [output selector fields]. These additions provide greater control and insight over [input selectors], complementing the new `argsMemoize` API.\n  - Introduced `inputStabilityCheck`, a development tool that runs the [input selectors] twice using the same arguments and triggers a warning If they return differing results for the same call.\n  - Introduced `identityFunctionCheck`, a development tool that checks to see if the [result function] returns its own input.\n\nThese updates aim to enhance flexibility, performance, and developer experience. For detailed usage and examples, refer to the updated documentation sections for each feature.\n\n- **Breaking Changes**:\n\n  - Removed `ParametricSelector` and `OutputParametricSelector` types. Their functionalities are now integrated into `Selector` and `OutputSelector` respectively, which inherently support additional parameters.\n\n<div align=\"right\">[ <a href=\"installation\">↑ Back to top ↑</a> ]</div>\n\n---\n\n## License\n\nMIT\n\n## References\n\n<details><summary><b>Click to Expand</b></summary>\n\nOriginally inspired by getters in [NuclearJS](https://github.com/optimizely/nuclear-js.git), [subscriptions](https://github.com/Day8/re-frame#just-a-read-only-cursor) in [re-frame](https://github.com/Day8/re-frame) and this [proposal](https://github.com/reduxjs/redux/pull/169) from [speedskater](https://github.com/speedskater).\n\n[typescript-badge]: https://img.shields.io/badge/TypeScript-v4%2E7%2B-007ACC?style=for-the-badge&logo=TypeScript&logoColor=black&labelColor=blue&color=gray\n[build-badge]: https://img.shields.io/github/actions/workflow/status/reduxjs/reselect/build-and-test-types.yml?branch=master&style=for-the-badge\n[build]: https://github.com/reduxjs/reselect/actions/workflows/build-and-test-types.yml\n[npm-badge]: https://img.shields.io/npm/v/reselect.svg?style=for-the-badge\n[npm]: https://www.npmjs.org/package/reselect\n[coveralls-badge]: https://img.shields.io/coveralls/reduxjs/reselect/master.svg?style=for-the-badge\n[coveralls]: https://coveralls.io/github/reduxjs/reselect\n\n<!-- External Links -->\n\n[Redux]: https://redux.js.org 'Redux'\n[React]: https://react.dev 'React'\n[React-Redux]: https://react-redux.js.org 'React-Redux'\n\n<!-- Internal Links -->\n\n[selector]: #selector-function 'Selector Function'\n[input selectors]: #input-selectors 'Input Selectors'\n[output selector]: #output-selector 'Output Selector'\n[result function]: #result-function 'Result Function'\n[output selector fields]: https://reselect.js.org/api/createSelector#output-selector-fields 'Output Selector Fields'\n[`createSelector`]: https://reselect.js.org/api/createSelector 'createSelector'\n[`createSelectorCreator`]: https://reselect.js.org/api/createSelectorCreator 'createSelectorCreator'\n[`lruMemoize`]: https://reselect.js.org/api/lruMemoize 'lruMemoize'\n[`weakMapMemoize`]: https://reselect.js.org/api/weakMapMemoize 'weakMapMemoize'\n[`createStructuredSelector`]: https://reselect.js.org/api/createStructuredSelector 'createStructuredSelector'\n\n</details>\n","publish_time":1778860301952,"_cnpm_publish_time":1778860301952,"dist-tags":{"alpha":"5.0.0-alpha.2","beta":"5.0.0-beta.1","latest":"5.3.0","next":"5.0.0-rc.0","rc":"5.0.0-rc.1","rc1":"3.0.0-beta.1"}}