Socket
Socket
Sign inDemoInstall

re-reselect

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

re-reselect - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

80

CHANGELOG.md
# Change log
## 2.3.0
### New Features
- Do not include test files on publish
- Introduce new selectors' methods/properties:
- `dependencies` property
- `recomputations` method
- `resetRecomputations` method
## 2.2.0
* Fix cache object's `isValidCacheKey` method TS type definition
- Fix cache object's `isValidCacheKey` method TS type definition
### New Features
* Upgrade to babel 7
* Update dev dependencies
- Upgrade to babel 7
- Update dev dependencies
### Breaking Changes
### Breaking Changes (not considered worth a major release)

@@ -20,3 +30,3 @@ `Babel 7` in `loose` mode [doesn't add anymore `classCallCheck` utility to transpiled ES classes](https://babeljs.io/blog/2018/08/27/7.0.0#output-options). Cache object classes instantiated by mistake without new operator will now fail silently.

* Expose `cache` property
- Expose `cache` property

@@ -27,22 +37,22 @@ ## 2.0.0

* `cacheKey` values no more restricted by default to `number` or `string`
* `cacheKey` validation delegated to `cacheObject`'s `isValidCacheKey` method
* `selectorCreator` argument removed in favour of `options` object
* `console.warn` when `resolverFunction` returns invalid `cacheKey`
* `cacheObject` export names renamed _(old ones are deprecated)_:
* `FlatCacheObject` -> `FlatObjectCache`
* `FifoCacheObject` -> `FifoObjectCache`
* `LruCacheObject` -> `LruObjectCache`
- `cacheKey` values no more restricted by default to `number` or `string`
- `cacheKey` validation delegated to `cacheObject`'s `isValidCacheKey` method
- `selectorCreator` argument removed in favour of `options` object
- `console.warn` when `resolverFunction` returns invalid `cacheKey`
- `cacheObject` export names renamed _(old ones are deprecated)_:
- `FlatCacheObject` -> `FlatObjectCache`
- `FifoCacheObject` -> `FifoObjectCache`
- `LruCacheObject` -> `LruObjectCache`
### New Features
* Added 3 new `cacheObject` implementations using `ES Map` objects accepting any value as `cacheKey`:
* `FlatMapCache`
* `FifoMapCache`
* `LruMapCache`
* Add a `sideEffects: false` flag for Webpack 4
- Added 3 new `cacheObject` implementations using `ES Map` objects accepting any value as `cacheKey`:
- `FlatMapCache`
- `FifoMapCache`
- `LruMapCache`
- Add a `sideEffects: false` flag for Webpack 4
## 1.0.1
* Remove wrong line at the beginning of the docs
- Remove wrong line at the beginning of the docs

@@ -53,50 +63,50 @@ ## 1.0.0

* `selectorCreator` argument is deprecated in favour of an option object
- `selectorCreator` argument is deprecated in favour of an option object
### New Features
* Accept an option object to provide `cacheObject` and `selectorCreator` options
* Extract caching logic into pluggable/customizable cache objects
* Introduce `Rollup.js` as bundler
* Make compilation cross-platform
- Accept an option object to provide `cacheObject` and `selectorCreator` options
- Extract caching logic into pluggable/customizable cache objects
- Introduce `Rollup.js` as bundler
- Make compilation cross-platform
## 0.6.3
* Add TS type definition for optional `selectorCreator`
- Add TS type definition for optional `selectorCreator`
## 0.6.2
* Fix wrong UMD reselect global import
- Fix wrong UMD reselect global import
## 0.6.1
* Fix TypeScript `OutputCachedSelector` and `OutputParametricCachedSelector` type definitions
- Fix TypeScript `OutputCachedSelector` and `OutputParametricCachedSelector` type definitions
## 0.6.0
* Add TypeScript type definitions
- Add TypeScript type definitions
## 0.5.0
* Expose `resultFunc` attribute
- Expose `resultFunc` attribute
## 0.4.0
* Expose `removeMatchingSelector` method
* Expose `clearCache` method
- Expose `removeMatchingSelector` method
- Expose `clearCache` method
## 0.3.0
* Add UMD dist
- Add UMD dist
## 0.2.0
* Expose `getMatchingSelector` method to retrieve the instance of cached selectors
- Expose `getMatchingSelector` method to retrieve the instance of cached selectors
## 0.1.0
* Allow resolver function to return keys of type number
- Allow resolver function to return keys of type number
## 0.0.0
* Initial release
- Initial release

@@ -303,4 +303,15 @@ (function (global, factory) {

throw new Error('[re-reselect] Second argument "options" must be an object. Please use "options.selectorCreator" to provide a custom selectorCreator.');
}
} // https://github.com/reduxjs/reselect/blob/v4.0.0/src/index.js#L54
var recomputations = 0;
var resultFunc = funcs.pop();
var dependencies = Array.isArray(funcs[0]) ? funcs[0] : [].concat(funcs);
var resultFuncWithRecomputations = function resultFuncWithRecomputations() {
recomputations++;
return resultFunc.apply(void 0, arguments);
};
funcs.push(resultFuncWithRecomputations);
var cache = options.cacheObject || new defaultCacheCreator();

@@ -344,4 +355,14 @@ var selectorCreator = options.selectorCreator || reselect.createSelector;

selector.resultFunc = funcs[funcs.length - 1];
selector.resultFunc = resultFunc;
selector.dependencies = dependencies;
selector.cache = cache;
selector.recomputations = function () {
return recomputations;
};
selector.resetRecomputations = function () {
return recomputations = 0;
};
return selector;

@@ -348,0 +369,0 @@ };

@@ -299,4 +299,15 @@ import { createSelector } from 'reselect';

throw new Error('[re-reselect] Second argument "options" must be an object. Please use "options.selectorCreator" to provide a custom selectorCreator.');
}
} // https://github.com/reduxjs/reselect/blob/v4.0.0/src/index.js#L54
var recomputations = 0;
var resultFunc = funcs.pop();
var dependencies = Array.isArray(funcs[0]) ? funcs[0] : [].concat(funcs);
var resultFuncWithRecomputations = function resultFuncWithRecomputations() {
recomputations++;
return resultFunc.apply(void 0, arguments);
};
funcs.push(resultFuncWithRecomputations);
var cache = options.cacheObject || new defaultCacheCreator();

@@ -340,4 +351,14 @@ var selectorCreator = options.selectorCreator || createSelector;

selector.resultFunc = funcs[funcs.length - 1];
selector.resultFunc = resultFunc;
selector.dependencies = dependencies;
selector.cache = cache;
selector.recomputations = function () {
return recomputations;
};
selector.resetRecomputations = function () {
return recomputations = 0;
};
return selector;

@@ -344,0 +365,0 @@ };

@@ -303,4 +303,15 @@ 'use strict';

throw new Error('[re-reselect] Second argument "options" must be an object. Please use "options.selectorCreator" to provide a custom selectorCreator.');
}
} // https://github.com/reduxjs/reselect/blob/v4.0.0/src/index.js#L54
var recomputations = 0;
var resultFunc = funcs.pop();
var dependencies = Array.isArray(funcs[0]) ? funcs[0] : [].concat(funcs);
var resultFuncWithRecomputations = function resultFuncWithRecomputations() {
recomputations++;
return resultFunc.apply(void 0, arguments);
};
funcs.push(resultFuncWithRecomputations);
var cache = options.cacheObject || new defaultCacheCreator();

@@ -344,4 +355,14 @@ var selectorCreator = options.selectorCreator || reselect.createSelector;

selector.resultFunc = funcs[funcs.length - 1];
selector.resultFunc = resultFunc;
selector.dependencies = dependencies;
selector.cache = cache;
selector.recomputations = function () {
return recomputations;
};
selector.resetRecomputations = function () {
return recomputations = 0;
};
return selector;

@@ -348,0 +369,0 @@ };

{
"name": "re-reselect",
"version": "2.2.0",
"version": "2.3.0",
"description": "Enhance Reselect selectors with deeper memoization and cache management",

@@ -14,3 +14,5 @@ "main": "lib/index.js",

"lib",
"src"
"src",
"!__tests__",
"!__util__"
],

@@ -63,3 +65,3 @@ "scripts": {

"prettier": "^1.11.1",
"reselect": ">1.0.0",
"reselect": "^4.0.0",
"rimraf": "^2.6.1",

@@ -66,0 +68,0 @@ "rollup": "^0.66.6",

@@ -19,6 +19,6 @@ # Re-reselect

* **retain selector's cache** when sequentially **called with one/few different arguments** ([example][example-1])
* **join similar selectors** into one
* **share selectors** with props across multiple components (see [reselect example][reselect-sharing-selectors] and [re-reselect solution][example-2])
* **instantiate** selectors **on runtime**
- **retain selector's cache** when sequentially **called with one/few different arguments** ([example][example-1])
- **join similar selectors** into one
- **share selectors** with props across multiple component instances (see [reselect example][reselect-sharing-selectors] and [re-reselect solution][example-2])
- **instantiate** selectors **on runtime**

@@ -61,21 +61,37 @@ <!-- prettier-ignore -->

* [Installation](#installation)
* [Why? + example](#why--example)
* [Re-reselect solution](#re-reselect-solution)
* [Other viable solutions](#other-viable-solutions)
* [FAQ](#faq)
* [How do I wrap my existing selector with re-reselect?](#how-do-i-wrap-my-existing-selector-with-re-reselect)
* [How do I use multiple inputs to set the cacheKey?](#how-do-i-use-multiple-inputs-to-set-the-cachekey)
* [How do I limit the cache size?](#how-do-i-limit-the-cache-size)
* [How to share a selector across multiple components while passing in props and retaining memoization?](#how-to-share-a-selector-across-multiple-components-while-passing-in-props-and-retaining-memoization)
* [How do I test a re-reselect selector?](#how-do-i-test-a-re-reselect-selector)
* [Examples](#examples)
* [API](#api)
* [`reReselect`](#rereselectreselects-createselector-argumentsresolverfunction--cacheobject-selectorcreator-)
* [reReselectInstance`()`](#rereselectinstanceselectorarguments)
* [reReselectInstance`.getMatchingSelector`](#rereselectinstancegetmatchingselectorselectorarguments)
* [reReselectInstance`.removeMatchingSelector`](#rereselectinstanceremovematchingselectorselectorarguments)
* [reReselectInstance`.clearCache`](#rereselectinstanceclearcache)
* [reReselectInstance`.resultFunc`](#rereselectinstanceresultfunc)
* [reReselectInstance`.cache`](#rereselectinstancecache)
- [Re-reselect](#re-reselect)
- [Table of contents](#table-of-contents)
- [Installation](#installation)
- [Why? + example](#why--example)
- [Re-reselect solution](#re-reselect-solution)
- [Other viable solutions](#other-viable-solutions)
- [1- Declare a different selector for each different call](#1--declare-a-different-selector-for-each-different-call)
- [2- Declare a `makeGetPieceOfData` selector factory as explained in Reselect docs](#2--declare-a-makegetpieceofdata-selector-factory-as-explained-in-reselect-docs)
- [3- Wrap your `makeGetPieceOfData` selector factory into a memoizer function and call the returning memoized selector](#3--wrap-your-makegetpieceofdata-selector-factory-into-a-memoizer-function-and-call-the-returning-memoized-selector)
- [Examples](#examples)
- [FAQ](#faq)
- [How do I wrap my existing selector with re-reselect?](#how-do-i-wrap-my-existing-selector-with-re-reselect)
- [How do I use multiple inputs to set the cacheKey?](#how-do-i-use-multiple-inputs-to-set-the-cachekey)
- [How do I limit the cache size?](#how-do-i-limit-the-cache-size)
- [How to share a selector across multiple components while passing in props and retaining memoization?](#how-to-share-a-selector-across-multiple-components-while-passing-in-props-and-retaining-memoization)
- [How do I test a re-reselect selector?](#how-do-i-test-a-re-reselect-selector)
- [Testing `reselect` selectors stored in the cache](#testing-reselect-selectors-stored-in-the-cache)
- [API](#api)
- [reReselect([reselect's createSelector arguments])(resolverFunction, { cacheObject, selectorCreator })](#rereselectreselects-createselector-argumentsresolverfunction--cacheobject-selectorcreator)
- [resolverFunction](#resolverfunction)
- [options.cacheObject](#optionscacheobject)
- [Custom cache strategy object](#custom-cache-strategy-object)
- [options.selectorCreator](#optionsselectorcreator)
- [Returns](#returns)
- [reReselectInstance(selectorArguments)](#rereselectinstanceselectorarguments)
- [reReselectInstance`.getMatchingSelector(selectorArguments)`](#rereselectinstancegetmatchingselectorselectorarguments)
- [reReselectInstance`.removeMatchingSelector(selectorArguments)`](#rereselectinstanceremovematchingselectorselectorarguments)
- [reReselectInstance`.cache`](#rereselectinstancecache)
- [reReselectInstance`.clearCache()`](#rereselectinstanceclearcache)
- [reReselectInstance`.dependencies`](#rereselectinstancedependencies)
- [reReselectInstance`.resultFunc`](#rereselectinstanceresultfunc)
- [reReselectInstance`.recomputations()`](#rereselectinstancerecomputations)
- [reReselectInstance`.resetRecomputations()`](#rereselectinstanceresetrecomputations)
- [Todo's](#todos)
- [Contributors](#contributors)

@@ -115,4 +131,4 @@ ## Installation

* takes the same arguments as the final selector (in the example: `state`, `itemId`, `'dataX'`)
* returns a `cacheKey`.
- takes the same arguments as the final selector (in the example: `state`, `itemId`, `'dataX'`)
- returns a `cacheKey`.

@@ -152,9 +168,9 @@ Note that the **same `reselect` selector instance** stored in cache will be used for computing data for the **same `cacheKey`** (1:1).

#### 2- Declare a `makeGetPieceOfData` selector factory as explained in [Reselect docs][reselect-sharing-selectors]
#### 2- Declare a `makeGetPieceOfData` selector factory as explained in Reselect docs
Fine, but has a few downsides:
The solution suggested in [Reselect docs][reselect-sharing-selectors] is fine, but it has a few downsides:
* Bloats your code by exposing both `get` selectors and `makeGet` selector factories
* Needs to import/call selector factory instead of directly using selector
* Two different instances given the same arguments, will individually store and recompute the same result (read [this](https://github.com/reactjs/reselect/pull/213))
- Bloats your code by exposing both `get` selectors and `makeGet` selector factories
- Needs to import/call selector factory instead of directly using selector
- Two different instances given the same arguments, will individually store and recompute the same result (read [this](https://github.com/reactjs/reselect/pull/213))

@@ -167,5 +183,5 @@ #### 3- Wrap your `makeGetPieceOfData` selector factory into a memoizer function and call the returning memoized selector

* [Join similar selectors][example-1]
* [Avoid selector factories][example-2]
* [Cache API calls][example-3]
- [Join similar selectors][example-1]
- [Avoid selector factories][example-2]
- [Cache API calls][example-3]

@@ -256,4 +272,15 @@ ## FAQ

Just like a normal reselect selector! Read more [here][reselect-test-selectors].
Just like a normal reselect selector!
`re-reselect` selectors expose the same `reselect` testing methods:
- `dependencies`
- `resultFunc`
- `recomputations`
- `resetRecomputations`
Read more about testing selectors on [`reselect` docs][reselect-test-selectors].
#### Testing `reselect` selectors stored in the cache
Each **re-reselect** selector exposes a `getMatchingSelector` method which returns the **underlying matching selector** instance for the given arguments, **instead of the result**.

@@ -263,8 +290,4 @@

Once you get a selector instance you can call [its public methods][reselect-selectors-methods] like:
Once you get a selector instance you can call [its public methods][reselect-selectors-methods].
* `resultFunc`
* `recomputations`
* `resetRecomputations`
<!-- prettier-ignore -->

@@ -310,4 +333,4 @@ ```js

* `resolverFunction`
* `options { cacheObject, selectorCreator }` _(optional)_
- `resolverFunction`
- `options { cacheObject, selectorCreator }` _(optional)_

@@ -395,2 +418,6 @@ #### resolverFunction

### reReselectInstance`.cache`
Get cacheObject instance being used by the selector (for advanced caching operations like [this](https://github.com/toomuchdesign/re-reselect/issues/40)).
### reReselectInstance`.clearCache()`

@@ -400,15 +427,24 @@

### reReselectInstance`.dependencies`
Get an array containing the provided `inputSelectors`. Refer to relevant discussion on [Reselect repo][reselect-test-selectors-dependencies].
### reReselectInstance`.resultFunc`
Get `resultFunc` for easily [test composed selectors][reselect-test-selectors].
Get `resultFunc` for easily [testing composed selectors][reselect-test-selectors].
### reReselectInstance`.cache`
### reReselectInstance`.recomputations()`
Get cacheObject instance being used by the selector (for advanced caching operations like [this](https://github.com/toomuchdesign/re-reselect/issues/40)).
Return the number of times the selector's result function has been recomputed.
### reReselectInstance`.resetRecomputations()`
Reset `recomputations` count.
## Todo's
* Flow type definitions?
* Improve TS tests readability
* More examples
- Introduce typings for heterogeneous selectors. See [this](https://github.com/reduxjs/reselect/pull/274) and [this](https://github.com/toomuchdesign/re-reselect/pull/63).
- Consider introducing typings for `selector.dependencies` method
- Improve TS tests readability
- More examples

@@ -425,3 +461,3 @@ ## Contributors

| [<img src="https://avatars2.githubusercontent.com/u/1428826?v=4" width="100px;"/><br /><sub><b>Gaurav Lahoti</b></sub>](https://github.com/Dante-101)<br />[🐛](https://github.com/toomuchdesign/re-reselect/issues?q=author%3ADante-101 "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/13602053?v=4" width="100px;"/><br /><sub><b>Lon</b></sub>](http://lon.im)<br />[🐛](https://github.com/toomuchdesign/re-reselect/issues?q=author%3Acnlon "Bug reports") | [<img src="https://avatars2.githubusercontent.com/u/5492495?v=4" width="100px;"/><br /><sub><b>bratushka</b></sub>](https://github.com/bratushka)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=bratushka "Code") | [<img src="https://avatars3.githubusercontent.com/u/615381?v=4" width="100px;"/><br /><sub><b>Anders D. Johnson</b></sub>](https://andrz.me)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=AndersDJohnson "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/8556724?v=4" width="100px;"/><br /><sub><b>Július Retzer</b></sub>](https://github.com/wormyy)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=wormyy "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/10407025?v=4" width="100px;"/><br /><sub><b>Maarten Schumacher</b></sub>](https://github.com/maartenschumacher)<br />[🤔](#ideas-maartenschumacher "Ideas, Planning, & Feedback") | [<img src="https://avatars2.githubusercontent.com/u/664238?v=4" width="100px;"/><br /><sub><b>Alexander Jarvis</b></sub>](https://github.com/alexanderjarvis)<br />[🤔](#ideas-alexanderjarvis "Ideas, Planning, & Feedback") |
| [<img src="https://avatars1.githubusercontent.com/u/514026?v=4" width="100px;"/><br /><sub><b>Gregg B</b></sub>](https://github.com/greggb)<br />[💡](#example-greggb "Examples") | [<img src="https://avatars0.githubusercontent.com/u/897931?v=4" width="100px;"/><br /><sub><b>Ian Obermiller</b></sub>](http://ianobermiller.com)<br />[👀](#review-ianobermiller "Reviewed Pull Requests") | [<img src="https://avatars3.githubusercontent.com/u/7040242?v=4" width="100px;"/><br /><sub><b>Kanitkorn Sujautra</b></sub>](https://github.com/lukyth)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=lukyth "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/6233440?v=4" width="100px;"/><br /><sub><b>Brian Kraus</b></sub>](https://github.com/suark)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=suark "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/9800850?v=4" width="100px;"/><br /><sub><b>Mateusz Burzyński</b></sub>](https://github.com/Andarist)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=Andarist "Code") [🚇](#infra-Andarist "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars1.githubusercontent.com/u/7252227?v=4" width="100px;"/><br /><sub><b>el-dav</b></sub>](https://github.com/el-dav)<br />[🐛](https://github.com/toomuchdesign/re-reselect/issues?q=author%3Ael-dav "Bug reports") |
| [<img src="https://avatars1.githubusercontent.com/u/514026?v=4" width="100px;"/><br /><sub><b>Gregg B</b></sub>](https://github.com/greggb)<br />[💡](#example-greggb "Examples") | [<img src="https://avatars0.githubusercontent.com/u/897931?v=4" width="100px;"/><br /><sub><b>Ian Obermiller</b></sub>](http://ianobermiller.com)<br />[👀](#review-ianobermiller "Reviewed Pull Requests") | [<img src="https://avatars3.githubusercontent.com/u/7040242?v=4" width="100px;"/><br /><sub><b>Kanitkorn Sujautra</b></sub>](https://github.com/lukyth)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=lukyth "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/6233440?v=4" width="100px;"/><br /><sub><b>Brian Kraus</b></sub>](https://github.com/suark)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=suark "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/9800850?v=4" width="100px;"/><br /><sub><b>Mateusz Burzyński</b></sub>](https://github.com/Andarist)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=Andarist "Code") [🚇](#infra-Andarist "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars1.githubusercontent.com/u/7252227?v=4" width="100px;"/><br /><sub><b>el-dav</b></sub>](https://github.com/el-dav)<br />[🐛](https://github.com/toomuchdesign/re-reselect/issues?q=author%3Ael-dav "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/15995890?v=4" width="100px;"/><br /><sub><b>Sergei Grishchenko</b></sub>](https://github.com/sgrishchenko)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=sgrishchenko "Code") [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=sgrishchenko "Tests") |

@@ -431,7 +467,8 @@ <!-- ALL-CONTRIBUTORS-LIST:END -->

[reselect]: https://github.com/reactjs/reselect
[reselect-sharing-selectors]: https://github.com/reactjs/reselect/tree/v3.0.1#sharing-selectors-with-props-across-multiple-components
[reselect-test-selectors]: https://github.com/reactjs/reselect/tree/v3.0.1#q-how-do-i-test-a-selector
[reselect-selectors-methods]: https://github.com/reactjs/reselect/blob/v3.0.1/src/index.js#L81
[reselect-create-selector]: https://github.com/reactjs/reselect/tree/v3.0.1#createselectorinputselectors--inputselectors-resultfunc
[reselect-create-selector-creator]: https://github.com/reactjs/reselect/tree/v3.0.1#createselectorcreatormemoize-memoizeoptions
[reselect-sharing-selectors]: https://github.com/reduxjs/reselect/tree/v4.0.0#sharing-selectors-with-props-across-multiple-component-instances
[reselect-test-selectors]: https://github.com/reactjs/reselect/tree/v4.0.0#q-how-do-i-test-a-selector
[reselect-test-selectors-dependencies]: https://github.com/reduxjs/reselect/issues/76#issuecomment-299194186
[reselect-selectors-methods]: https://github.com/reduxjs/reselect/blob/v4.0.0/src/index.js#L81
[reselect-create-selector]: https://github.com/reactjs/reselect/tree/v4.0.0#createselectorinputselectors--inputselectors-resultfunc
[reselect-create-selector-creator]: https://github.com/reactjs/reselect/tree/v4.0.0#createselectorcreatormemoize-memoizeoptions
[lodash-memoize]: https://lodash.com/docs/4.17.4#memoize

@@ -438,0 +475,0 @@ [ci-badge]: https://travis-ci.org/toomuchdesign/re-reselect.svg?branch=master

@@ -33,3 +33,2 @@ import {createSelector} from 'reselect';

clearCache: () => void;
resultFunc: C;
cache: ICacheObject;

@@ -71,3 +70,2 @@ };

clearCache: () => void;
resultFunc: C;
cache: ICacheObject;

@@ -74,0 +72,0 @@ };

@@ -16,2 +16,13 @@ import {createSelector} from 'reselect';

// https://github.com/reduxjs/reselect/blob/v4.0.0/src/index.js#L54
let recomputations = 0;
const resultFunc = funcs.pop();
const dependencies = Array.isArray(funcs[0]) ? funcs[0] : [...funcs];
const resultFuncWithRecomputations = (...args) => {
recomputations++;
return resultFunc(...args);
};
funcs.push(resultFuncWithRecomputations);
const cache = options.cacheObject || new defaultCacheCreator();

@@ -57,6 +68,12 @@ const selectorCreator = options.selectorCreator || createSelector;

selector.resultFunc = funcs[funcs.length - 1];
selector.resultFunc = resultFunc;
selector.dependencies = dependencies;
selector.cache = cache;
selector.recomputations = () => recomputations;
selector.resetRecomputations = () => (recomputations = 0);
return selector;

@@ -63,0 +80,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc