{"name":"reselect","version":"4.0.0","keywords":["react","redux"],"license":"MIT","_id":"reselect@4.0.0","maintainers":[{"name":"alex3165","email":"alexr.3165@gmail.com"},{"name":"ellbee","email":"l_bannard@yahoo.co.uk"},{"name":"faassen","email":"faassen@startifact.com"},{"name":"gaearon","email":"dan.abramov@gmail.com"},{"name":"threehams","email":"threehams@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":"f2529830e5d3d0e021408b246a206ef4ea4437f7","tarball":"http://registry-npm.ywwl.com/reselect/download/reselect-4.0.0.tgz","fileCount":11,"integrity":"sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==","signatures":[{"sig":"MEYCIQC9J1ORmRcyL+l8iuDrWU8QUMlECUHcLmbuh8+ePykmPgIhANwSxi2iSBf3rCx4lSCHulvTgYT1gJ/ZYTJqDfr6UZRK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":171495,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbsLXlCRA9TVsSAnZWagAAfUoP/1fY2YsQ5KgSbBL4TniU\nw+iHK98yXHJ1BNfwKiCrN69PLPdhkcabmyQ2BqPgBt2XXC7oWwBr9gO4Ac0g\nQhDY4ghAEjXwjGn+8p4OcqXRHmFNbGBBE5HWGIlMRAIfKDldQIaQX6VvFYzN\nWraWiBNd5KyJ0lYVxifOHyplG6iiT8sxbVDY3qOxF96kv+DEha8H7o8kV0UF\nTq8OtqT0nlHbWzPjDqATIYAHV6x8hFqQo2D2eAsMmjZKCSFFU8MHdqfJxwgQ\n8iG0bz8+/pOKdaHr95MzJRmlBfETMn1rZXINMeeLm2YemKo0mMVMap2Gbk3y\naeKw7P81Zm+rZwq5whgjrb/8aAc7L1nzxpHFuMa3525Txukt1aL1pNxpNXFM\nFzV5bV/Af0yZfudoBjQ6ce/umFni5DUyGAbiRLwft4j+AMJoU7B6vwLfFLGZ\nNyXXvJwYNdL6j0ET84Mdktyq0vDSxDFuB/2mwQifqcSNGanF7mmx4zj+TXzb\nmvr3soVLKRVr09zQTT1EPAmHoYMp2S+3llCgG52T9jN1A62eb1qev8qPlBHl\nQ2w6OG9BGmRfKNbRyNSNOH4t3dbBHJk/wgwEZbED1rUYGjuVVeSMUX7b1FMo\nh6+VllPLPFdZFzcSxGgOngkjJ1xLdYDdM7NROiGyAeA4Rp9R5UcwpXG+EVse\nxX1I\r\n=/V6n\r\n-----END PGP SIGNATURE-----\r\n","size":23438,"noattachment":false,"key":"/reselect/-/reselect-4.0.0.tgz"},"main":"lib/index.js","module":"es/index.js","authors":["Lee Bannard","Robert Binna","Martijn Faassen","Philip Spitzlinger"],"gitHead":"1f3fdeb22c3fef1b4a212f16b814b5fd9fdf07a9","scripts":{"lint":"eslint src test","test":"better-npm-run test","compile":"npm run compile:commonjs && npm run compile:umd && npm run compile:umdmin && npm run compile:es","test:cov":"better-npm-run test:cov","compile:es":"babel -d es/ src/","prepublish":"npm run compile","compile:umd":"better-npm-run compile:umd","compile:umdmin":"uglifyjs dist/reselect.js -mt -o dist/reselect.min.js","test:typescript":"better-npm-run test:typescript","compile:commonjs":"better-npm-run compile:commonjs"},"typings":"lib/index.d.ts","_npmUser":{"name":"ellbee","email":"l_bannard@yahoo.co.uk"},"repository":{"url":"git+https://github.com/reduxjs/reselect.git","type":"git"},"_npmVersion":"6.4.1","description":"Selectors for Redux.","directories":{},"jsnext:main":"es/index.js","_nodeVersion":"9.11.1","betterScripts":{"test":{"env":{"NODE_ENV":"test"},"command":"mocha --compilers js:babel-register --ui tdd --recursive"},"test:cov":{"env":{"COVERAGE":"true","NODE_ENV":"test"},"command":"nyc --reporter=lcov --reporter=text mocha --compilers js:babel-register --ui tdd"},"compile:umd":{"env":{"NODE_ENV":"umd"},"command":"mkdirp dist/ && babel -o dist/reselect.js src/"},"test:typescript":{"command":"typings-tester --dir typescript_test"},"compile:commonjs":{"env":{"NODE_ENV":"commonjs"},"command":"babel -d lib/ src/ && ncp ./src/index.d.ts ./lib/index.d.ts"}},"_hasShrinkwrap":false,"devDependencies":{"ncp":"^2.0.0","nyc":"^6.4.0","chai":"^3.0.0","mocha":"^2.2.5","eslint":"^2.11","mkdirp":"^0.5.1","babel-cli":"^6.7.5","coveralls":"^2.11.4","uglify-js":"^3.0.20","codecov.io":"^0.1.6","typescript":"^2.9.2","babel-register":"^6.7.2","better-npm-run":"0.0.8","lodash.memoize":"^4.1.0","typings-tester":"^0.2.0","eslint-plugin-react":"^5.1.1","babel-plugin-check-es2015-constants":"^6.7.2","babel-plugin-transform-es2015-spread":"^6.6.5","babel-plugin-transform-es2015-parameters":"^6.7.0","babel-plugin-transform-es2015-modules-umd":"^6.6.5","babel-plugin-transform-es2015-block-scoping":"^6.7.1","babel-plugin-transform-es2015-function-name":"^6.5.0","babel-plugin-transform-es2015-arrow-functions":"^6.5.2","babel-plugin-transform-es2015-modules-commonjs":"^6.7.4","babel-plugin-transform-es2015-template-literals":"^6.6.5","babel-plugin-transform-es2015-shorthand-properties":"^6.5.0"},"_npmOperationalInternal":{"tmp":"tmp/reselect_4.0.0_1538307556892_0.09388397927391567","host":"s3://npm-registry-packages"},"readme":"# Reselect\r\n\r\n[![npm package][npm-badge]][npm][![Coveralls][coveralls-badge]][coveralls][![GitHub Workflow Status][build-badge]][build]![TypeScript][typescript-badge]\r\n\r\nA library for creating memoized \"selector\" functions. Commonly used with Redux, but usable with any plain JS immutable data as well.\r\n\r\n- Selectors can compute derived data, allowing [Redux] to store the minimal possible state.\r\n- Selectors are efficient. A selector is not recomputed unless one of its arguments changes.\r\n- Selectors are composable. They can be used as input to other selectors.\r\n\r\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].\r\n\r\n## Installation\r\n\r\n### Redux Toolkit\r\n\r\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.\r\n\r\n```ts\r\nimport { createSelector } from '@reduxjs/toolkit'\r\n```\r\n\r\n### Standalone\r\n\r\nFor standalone usage, install the `reselect` package:\r\n\r\n```bash\r\n# NPM\r\nnpm install reselect\r\n\r\n# Yarn\r\nyarn add reselect\r\n```\r\n\r\n---\r\n\r\n## Documentation\r\n\r\nThe Reselect docs are available at **https://reselect.js.org**, and include usage guides and API references:\r\n\r\n- [**Introduction**](#https://reselect.js.org/introduction/getting-started)\r\n- [**How Does Reselect Work?**](#https://reselect.js.org/introduction/how-does-reselect-work)\r\n- **API Reference**:\r\n  - **[`createSelector`]**\r\n  - **[`createSelectorCreator`]**\r\n  - **[`createStructuredSelector`]**\r\n  - [**Development-Only Stability Checks**](#https://reselect.js.org/api/development-only-stability-checks)\r\n  - **[`lruMemoize`]**\r\n  - **[`weakMapMemoize`]**\r\n- [**FAQ**](#https://reselect.js.org/FAQ)\r\n\r\n## Basic Usage\r\n\r\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.\r\n\r\nYou can play around with the following **example** in [this CodeSandbox](https://codesandbox.io/s/reselect-example-g3k9gf?file=/src/index.js):\r\n\r\n```ts\r\nimport { createSelector } from 'reselect'\r\n\r\ninterface RootState {\r\n  todos: { id: number; completed: boolean }[]\r\n  alerts: { id: number; read: boolean }[]\r\n}\r\n\r\nconst state: RootState = {\r\n  todos: [\r\n    { id: 0, completed: false },\r\n    { id: 1, completed: true }\r\n  ],\r\n  alerts: [\r\n    { id: 0, read: false },\r\n    { id: 1, read: true }\r\n  ]\r\n}\r\n\r\nconst selectCompletedTodos = (state: RootState) => {\r\n  console.log('selector ran')\r\n  return state.todos.filter(todo => todo.completed === true)\r\n}\r\n\r\nselectCompletedTodos(state) // selector ran\r\nselectCompletedTodos(state) // selector ran\r\nselectCompletedTodos(state) // selector ran\r\n\r\nconst memoizedSelectCompletedTodos = createSelector(\r\n  [(state: RootState) => state.todos],\r\n  todos => {\r\n    console.log('memoized selector ran')\r\n    return todos.filter(todo => todo.completed === true)\r\n  }\r\n)\r\n\r\nmemoizedSelectCompletedTodos(state) // memoized selector ran\r\nmemoizedSelectCompletedTodos(state)\r\nmemoizedSelectCompletedTodos(state)\r\n\r\nconsole.log(selectCompletedTodos(state) === selectCompletedTodos(state)) //=> false\r\n\r\nconsole.log(\r\n  memoizedSelectCompletedTodos(state) === memoizedSelectCompletedTodos(state)\r\n) //=> true\r\n```\r\n\r\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.\r\n\r\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.\r\n\r\n---\r\n\r\n## Terminology\r\n\r\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.\r\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].\r\n- <a name=\"output-selector\"></a>[**Output Selector**](#output-selector): The actual memoized selectors created by [`createSelector`].\r\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.\r\n- <a name=\"dependencies\"></a>[**`Dependencies`**](#dependencies): Same as [input selectors]. They are what the [output selector] \"depends\" on.\r\n\r\nThe below example serves as a visual aid:\r\n\r\n```ts\r\nconst outputSelector = createSelector(\r\n  [inputSelector1, inputSelector2, inputSelector3], // synonymous with `dependencies`.\r\n  resultFunc // Result function\r\n)\r\n```\r\n\r\n---\r\n\r\n## What's New in 5.0.0?\r\n\r\nVersion 5.0.0 introduces several new features and improvements:\r\n\r\n- **Customization Enhancements**:\r\n\r\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`).\r\n  - The [`createSelector`] function now supports direct customization of `memoize` and `argsMemoize` within its options object.\r\n\r\n- **Memoization Functions**:\r\n\r\n  - Introduced new experimental memoization functions: `weakMapMemoize` and `unstable_autotrackMemoize`.\r\n  - Incorporated `memoize` and `argsMemoize` into the [output selector fields] for debugging purposes.\r\n\r\n- **TypeScript Support and Performance**:\r\n\r\n  - Discontinued support for TypeScript versions below 4.7, aligning with modern TypeScript features.\r\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.\r\n\r\n- **Selector API Enhancements**:\r\n\r\n  - Removed the second overload of `createStructuredSelector` due to its susceptibility to runtime errors.\r\n\r\n- **Additional Functionalities**:\r\n\r\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.\r\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.\r\n  - Introduced `identityFunctionCheck`, a development tool that checks to see if the [result function] returns its own input.\r\n\r\nThese updates aim to enhance flexibility, performance, and developer experience. For detailed usage and examples, refer to the updated documentation sections for each feature.\r\n\r\n- **Breaking Changes**:\r\n\r\n  - Removed `ParametricSelector` and `OutputParametricSelector` types. Their functionalities are now integrated into `Selector` and `OutputSelector` respectively, which inherently support additional parameters.\r\n\r\n<div align=\"right\">[ <a href=\"installation\">↑ Back to top ↑</a> ]</div>\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT\r\n\r\n## References\r\n\r\n<details><summary><b>Click to Expand</b></summary>\r\n\r\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).\r\n\r\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\r\n[build-badge]: https://img.shields.io/github/actions/workflow/status/reduxjs/reselect/build-and-test-types.yml?branch=master&style=for-the-badge\r\n[build]: https://github.com/reduxjs/reselect/actions/workflows/build-and-test-types.yml\r\n[npm-badge]: https://img.shields.io/npm/v/reselect.svg?style=for-the-badge\r\n[npm]: https://www.npmjs.org/package/reselect\r\n[coveralls-badge]: https://img.shields.io/coveralls/reduxjs/reselect/master.svg?style=for-the-badge\r\n[coveralls]: https://coveralls.io/github/reduxjs/reselect\r\n\r\n<!-- External Links -->\r\n\r\n[Redux]: https://redux.js.org 'Redux'\r\n[React]: https://react.dev 'React'\r\n[React-Redux]: https://react-redux.js.org 'React-Redux'\r\n\r\n<!-- Internal Links -->\r\n\r\n[selector]: #selector-function 'Selector Function'\r\n[input selectors]: #input-selectors 'Input Selectors'\r\n[output selector]: #output-selector 'Output Selector'\r\n[result function]: #result-function 'Result Function'\r\n[output selector fields]: https://reselect.js.org/api/createSelector#output-selector-fields 'Output Selector Fields'\r\n[`createSelector`]: https://reselect.js.org/api/createSelector 'createSelector'\r\n[`createSelectorCreator`]: https://reselect.js.org/api/createSelectorCreator 'createSelectorCreator'\r\n[`lruMemoize`]: https://reselect.js.org/api/lruMemoize 'lruMemoize'\r\n[`weakMapMemoize`]: https://reselect.js.org/api/weakMapMemoize 'weakMapMemoize'\r\n[`createStructuredSelector`]: https://reselect.js.org/api/createStructuredSelector 'createStructuredSelector'\r\n\r\n</details>\r\n","publish_time":1538307557055,"_cnpm_publish_time":1538307557055,"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"}}