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.1.0 to 2.2.0

13

CHANGELOG.md
# Change log
## 2.2.0
* Fix cache object's `isValidCacheKey` method TS type definition
### New Features
* Upgrade to babel 7
* Update dev dependencies
### Breaking Changes
`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.
## 2.1.0

@@ -4,0 +17,0 @@

531

dist/index.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reselect')) :
typeof define === 'function' && define.amd ? define(['exports', 'reselect'], factory) :
(factory((global['Re-reselect'] = {}),global.Reselect));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reselect')) :
typeof define === 'function' && define.amd ? define(['exports', 'reselect'], factory) :
(factory((global['Re-reselect'] = {}),global.Reselect));
}(this, (function (exports,reselect) { 'use strict';
function isStringOrNumber(value) {
return typeof value === 'string' || typeof value === 'number';
}
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
function isStringOrNumber(value) {
return typeof value === 'string' || typeof value === 'number';
}
};
var FlatObjectCache = function () {
function FlatObjectCache() {
classCallCheck(this, FlatObjectCache);
var FlatObjectCache =
/*#__PURE__*/
function () {
function FlatObjectCache() {
this._cache = {};
}
this._cache = {};
}
var _proto = FlatObjectCache.prototype;
FlatObjectCache.prototype.set = function set$$1(key, selectorFn) {
this._cache[key] = selectorFn;
};
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
};
FlatObjectCache.prototype.get = function get$$1(key) {
return this._cache[key];
};
_proto.get = function get(key) {
return this._cache[key];
};
FlatObjectCache.prototype.remove = function remove(key) {
delete this._cache[key];
};
_proto.remove = function remove(key) {
delete this._cache[key];
};
FlatObjectCache.prototype.clear = function clear() {
this._cache = {};
};
_proto.clear = function clear() {
this._cache = {};
};
FlatObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);
};
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);
};
return FlatObjectCache;
}();
return FlatObjectCache;
}();
function validateCacheSize(cacheSize) {
if (cacheSize === undefined) {
throw new Error('Missing the required property "cacheSize".');
}
if (!Number.isInteger(cacheSize) || cacheSize <= 0) {
throw new Error('The "cacheSize" property must be a positive integer value.');
}
}
function validateCacheSize(cacheSize) {
if (cacheSize === undefined) {
throw new Error('Missing the required property "cacheSize".');
}
var FifoObjectCache = function () {
function FifoObjectCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
cacheSize = _ref.cacheSize;
classCallCheck(this, FifoObjectCache);
validateCacheSize(cacheSize);
this._cache = {};
this._cacheOrdering = [];
this._cacheSize = cacheSize;
if (!Number.isInteger(cacheSize) || cacheSize <= 0) {
throw new Error('The "cacheSize" property must be a positive integer value.');
}
}
FifoObjectCache.prototype.set = function set$$1(key, selectorFn) {
this._cache[key] = selectorFn;
this._cacheOrdering.push(key);
var FifoObjectCache =
/*#__PURE__*/
function () {
function FifoObjectCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
if (this._cacheOrdering.length > this._cacheSize) {
var earliest = this._cacheOrdering[0];
this.remove(earliest);
validateCacheSize(cacheSize);
this._cache = {};
this._cacheOrdering = [];
this._cacheSize = cacheSize;
}
};
FifoObjectCache.prototype.get = function get$$1(key) {
return this._cache[key];
};
var _proto = FifoObjectCache.prototype;
FifoObjectCache.prototype.remove = function remove(key) {
var index = this._cacheOrdering.indexOf(key);
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
if (index > -1) {
this._cacheOrdering.splice(index, 1);
}
delete this._cache[key];
};
this._cacheOrdering.push(key);
FifoObjectCache.prototype.clear = function clear() {
this._cache = {};
this._cacheOrdering = [];
};
if (this._cacheOrdering.length > this._cacheSize) {
var earliest = this._cacheOrdering[0];
this.remove(earliest);
}
};
FifoObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);
};
_proto.get = function get(key) {
return this._cache[key];
};
return FifoObjectCache;
}();
_proto.remove = function remove(key) {
var index = this._cacheOrdering.indexOf(key);
var LruObjectCache = function () {
function LruObjectCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
cacheSize = _ref.cacheSize;
if (index > -1) {
this._cacheOrdering.splice(index, 1);
}
classCallCheck(this, LruObjectCache);
delete this._cache[key];
};
validateCacheSize(cacheSize);
this._cache = {};
this._cacheOrdering = [];
this._cacheSize = cacheSize;
}
_proto.clear = function clear() {
this._cache = {};
this._cacheOrdering = [];
};
LruObjectCache.prototype.set = function set$$1(key, selectorFn) {
this._cache[key] = selectorFn;
this._registerCacheHit(key);
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);
};
if (this._cacheOrdering.length > this._cacheSize) {
var earliest = this._cacheOrdering[0];
this.remove(earliest);
}
};
return FifoObjectCache;
}();
LruObjectCache.prototype.get = function get$$1(key) {
this._registerCacheHit(key);
return this._cache[key];
};
var LruObjectCache =
/*#__PURE__*/
function () {
function LruObjectCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
LruObjectCache.prototype.remove = function remove(key) {
this._deleteCacheHit(key);
delete this._cache[key];
};
validateCacheSize(cacheSize);
this._cache = {};
this._cacheOrdering = [];
this._cacheSize = cacheSize;
}
LruObjectCache.prototype.clear = function clear() {
this._cache = {};
this._cacheOrdering = [];
};
var _proto = LruObjectCache.prototype;
LruObjectCache.prototype._registerCacheHit = function _registerCacheHit(key) {
this._deleteCacheHit(key);
this._cacheOrdering.push(key);
};
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
LruObjectCache.prototype._deleteCacheHit = function _deleteCacheHit(key) {
var index = this._cacheOrdering.indexOf(key);
if (index > -1) {
this._cacheOrdering.splice(index, 1);
}
};
this._registerCacheHit(key);
LruObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);
};
if (this._cacheOrdering.length > this._cacheSize) {
var earliest = this._cacheOrdering[0];
this.remove(earliest);
}
};
return LruObjectCache;
}();
_proto.get = function get(key) {
this._registerCacheHit(key);
var FlatMapCache = function () {
function FlatMapCache() {
classCallCheck(this, FlatMapCache);
return this._cache[key];
};
this._cache = new Map();
}
_proto.remove = function remove(key) {
this._deleteCacheHit(key);
FlatMapCache.prototype.set = function set$$1(key, selectorFn) {
this._cache.set(key, selectorFn);
};
delete this._cache[key];
};
FlatMapCache.prototype.get = function get$$1(key) {
return this._cache.get(key);
};
_proto.clear = function clear() {
this._cache = {};
this._cacheOrdering = [];
};
FlatMapCache.prototype.remove = function remove(key) {
this._cache.delete(key);
};
_proto._registerCacheHit = function _registerCacheHit(key) {
this._deleteCacheHit(key);
FlatMapCache.prototype.clear = function clear() {
this._cache.clear();
};
this._cacheOrdering.push(key);
};
return FlatMapCache;
}();
_proto._deleteCacheHit = function _deleteCacheHit(key) {
var index = this._cacheOrdering.indexOf(key);
var FifoMapCache = function () {
function FifoMapCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
cacheSize = _ref.cacheSize;
if (index > -1) {
this._cacheOrdering.splice(index, 1);
}
};
classCallCheck(this, FifoMapCache);
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);
};
validateCacheSize(cacheSize);
this._cache = new Map();
this._cacheSize = cacheSize;
}
return LruObjectCache;
}();
FifoMapCache.prototype.set = function set$$1(key, selectorFn) {
this._cache.set(key, selectorFn);
if (this._cache.size > this._cacheSize) {
var earliest = this._cache.keys().next().value;
this.remove(earliest);
var FlatMapCache =
/*#__PURE__*/
function () {
function FlatMapCache() {
this._cache = new Map();
}
};
FifoMapCache.prototype.get = function get$$1(key) {
return this._cache.get(key);
};
var _proto = FlatMapCache.prototype;
FifoMapCache.prototype.remove = function remove(key) {
this._cache.delete(key);
};
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);
};
FifoMapCache.prototype.clear = function clear() {
this._cache.clear();
};
_proto.get = function get(key) {
return this._cache.get(key);
};
return FifoMapCache;
}();
_proto.remove = function remove(key) {
this._cache.delete(key);
};
var LruMapCache = function () {
function LruMapCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
cacheSize = _ref.cacheSize;
_proto.clear = function clear() {
this._cache.clear();
};
classCallCheck(this, LruMapCache);
return FlatMapCache;
}();
validateCacheSize(cacheSize);
this._cache = new Map();
this._cacheSize = cacheSize;
}
var FifoMapCache =
/*#__PURE__*/
function () {
function FifoMapCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
LruMapCache.prototype.set = function set$$1(key, selectorFn) {
this._cache.set(key, selectorFn);
if (this._cache.size > this._cacheSize) {
var earliest = this._cache.keys().next().value;
this.remove(earliest);
validateCacheSize(cacheSize);
this._cache = new Map();
this._cacheSize = cacheSize;
}
};
LruMapCache.prototype.get = function get$$1(key) {
var value = this._cache.get(key);
var _proto = FifoMapCache.prototype;
// Register cache hit
if (this._cache.has(key)) {
this.remove(key);
this._cache.set(key, value);
}
return value;
};
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);
LruMapCache.prototype.remove = function remove(key) {
this._cache.delete(key);
};
if (this._cache.size > this._cacheSize) {
var earliest = this._cache.keys().next().value;
LruMapCache.prototype.clear = function clear() {
this._cache.clear();
};
this.remove(earliest);
}
};
return LruMapCache;
}();
_proto.get = function get(key) {
return this._cache.get(key);
};
var defaultCacheCreator = FlatObjectCache;
var defaultCacheKeyValidator = function defaultCacheKeyValidator() {
return true;
};
_proto.remove = function remove(key) {
this._cache.delete(key);
};
function createCachedSelector() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
_proto.clear = function clear() {
this._cache.clear();
};
return function (resolver) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return FifoMapCache;
}();
// @NOTE Versions 0.x/1.x accepted "options" as a function
if (typeof options === 'function') {
throw new Error('[re-reselect] Second argument "options" must be an object. Please use "options.selectorCreator" to provide a custom selectorCreator.');
var LruMapCache =
/*#__PURE__*/
function () {
function LruMapCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
validateCacheSize(cacheSize);
this._cache = new Map();
this._cacheSize = cacheSize;
}
var cache = options.cacheObject || new defaultCacheCreator();
var selectorCreator = options.selectorCreator || reselect.createSelector;
var isValidCacheKey = cache.isValidCacheKey || defaultCacheKeyValidator;
var _proto = LruMapCache.prototype;
// Application receives this function
var selector = function selector() {
var cacheKey = resolver.apply(undefined, arguments);
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);
if (isValidCacheKey(cacheKey)) {
var cacheResponse = cache.get(cacheKey);
if (this._cache.size > this._cacheSize) {
var earliest = this._cache.keys().next().value;
if (cacheResponse === undefined) {
cacheResponse = selectorCreator.apply(undefined, funcs);
cache.set(cacheKey, cacheResponse);
}
return cacheResponse.apply(undefined, arguments);
this.remove(earliest);
}
console.warn('[re-reselect] Invalid cache key "' + cacheKey + '" has been returned by resolver function.');
return undefined;
};
// Further selector methods
selector.getMatchingSelector = function () {
var cacheKey = resolver.apply(undefined, arguments);
// @NOTE It might update cache hit count in LRU-like caches
return cache.get(cacheKey);
_proto.get = function get(key) {
var value = this._cache.get(key); // Register cache hit
if (this._cache.has(key)) {
this.remove(key);
this._cache.set(key, value);
}
return value;
};
selector.removeMatchingSelector = function () {
var cacheKey = resolver.apply(undefined, arguments);
cache.remove(cacheKey);
_proto.remove = function remove(key) {
this._cache.delete(key);
};
selector.clearCache = function () {
cache.clear();
_proto.clear = function clear() {
this._cache.clear();
};
selector.resultFunc = funcs[funcs.length - 1];
return LruMapCache;
}();
selector.cache = cache;
var defaultCacheCreator = FlatObjectCache;
return selector;
var defaultCacheKeyValidator = function defaultCacheKeyValidator() {
return true;
};
}
exports.default = createCachedSelector;
exports.FlatObjectCache = FlatObjectCache;
exports.FlatCacheObject = FlatObjectCache;
exports.FifoObjectCache = FifoObjectCache;
exports.LruObjectCache = LruObjectCache;
exports.FlatMapCache = FlatMapCache;
exports.FifoMapCache = FifoMapCache;
exports.LruMapCache = LruMapCache;
exports.FifoCacheObject = FifoObjectCache;
exports.LruCacheObject = LruMapCache;
function createCachedSelector() {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
Object.defineProperty(exports, '__esModule', { value: true });
return function (resolver, options) {
if (options === void 0) {
options = {};
}
// @NOTE Versions 0.x/1.x accepted "options" as a function
if (typeof options === 'function') {
throw new Error('[re-reselect] Second argument "options" must be an object. Please use "options.selectorCreator" to provide a custom selectorCreator.');
}
var cache = options.cacheObject || new defaultCacheCreator();
var selectorCreator = options.selectorCreator || reselect.createSelector;
var isValidCacheKey = cache.isValidCacheKey || defaultCacheKeyValidator; // Application receives this function
var selector = function selector() {
var cacheKey = resolver.apply(void 0, arguments);
if (isValidCacheKey(cacheKey)) {
var cacheResponse = cache.get(cacheKey);
if (cacheResponse === undefined) {
cacheResponse = selectorCreator.apply(void 0, funcs);
cache.set(cacheKey, cacheResponse);
}
return cacheResponse.apply(void 0, arguments);
}
console.warn("[re-reselect] Invalid cache key \"" + cacheKey + "\" has been returned by resolver function.");
return undefined;
}; // Further selector methods
selector.getMatchingSelector = function () {
var cacheKey = resolver.apply(void 0, arguments); // @NOTE It might update cache hit count in LRU-like caches
return cache.get(cacheKey);
};
selector.removeMatchingSelector = function () {
var cacheKey = resolver.apply(void 0, arguments);
cache.remove(cacheKey);
};
selector.clearCache = function () {
cache.clear();
};
selector.resultFunc = funcs[funcs.length - 1];
selector.cache = cache;
return selector;
};
}
exports.default = createCachedSelector;
exports.FlatObjectCache = FlatObjectCache;
exports.FlatCacheObject = FlatObjectCache;
exports.FifoObjectCache = FifoObjectCache;
exports.LruObjectCache = LruObjectCache;
exports.FlatMapCache = FlatMapCache;
exports.FifoMapCache = FifoMapCache;
exports.LruMapCache = LruMapCache;
exports.FifoCacheObject = FifoObjectCache;
exports.LruCacheObject = LruMapCache;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=index.js.map

@@ -7,32 +7,28 @@ import { createSelector } from 'reselect';

var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var FlatObjectCache = function () {
var FlatObjectCache =
/*#__PURE__*/
function () {
function FlatObjectCache() {
classCallCheck(this, FlatObjectCache);
this._cache = {};
}
FlatObjectCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FlatObjectCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
};
FlatObjectCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache[key];
};
FlatObjectCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
delete this._cache[key];
};
FlatObjectCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache = {};
};
FlatObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);

@@ -48,2 +44,3 @@ };

}
if (!Number.isInteger(cacheSize) || cacheSize <= 0) {

@@ -54,9 +51,9 @@ throw new Error('The "cacheSize" property must be a positive integer value.');

var FifoObjectCache = function () {
function FifoObjectCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var FifoObjectCache =
/*#__PURE__*/
function () {
function FifoObjectCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, FifoObjectCache);
validateCacheSize(cacheSize);

@@ -68,4 +65,7 @@ this._cache = {};

FifoObjectCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FifoObjectCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
this._cacheOrdering.push(key);

@@ -79,7 +79,7 @@

FifoObjectCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache[key];
};
FifoObjectCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
var index = this._cacheOrdering.indexOf(key);

@@ -90,6 +90,7 @@

}
delete this._cache[key];
};
FifoObjectCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache = {};

@@ -99,3 +100,3 @@ this._cacheOrdering = [];

FifoObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);

@@ -107,9 +108,9 @@ };

var LruObjectCache = function () {
function LruObjectCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var LruObjectCache =
/*#__PURE__*/
function () {
function LruObjectCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, LruObjectCache);
validateCacheSize(cacheSize);

@@ -121,4 +122,7 @@ this._cache = {};

LruObjectCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = LruObjectCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
this._registerCacheHit(key);

@@ -132,13 +136,15 @@

LruObjectCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
this._registerCacheHit(key);
return this._cache[key];
};
LruObjectCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._deleteCacheHit(key);
delete this._cache[key];
};
LruObjectCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache = {};

@@ -148,9 +154,11 @@ this._cacheOrdering = [];

LruObjectCache.prototype._registerCacheHit = function _registerCacheHit(key) {
_proto._registerCacheHit = function _registerCacheHit(key) {
this._deleteCacheHit(key);
this._cacheOrdering.push(key);
};
LruObjectCache.prototype._deleteCacheHit = function _deleteCacheHit(key) {
_proto._deleteCacheHit = function _deleteCacheHit(key) {
var index = this._cacheOrdering.indexOf(key);
if (index > -1) {

@@ -161,3 +169,3 @@ this._cacheOrdering.splice(index, 1);

LruObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);

@@ -169,22 +177,24 @@ };

var FlatMapCache = function () {
var FlatMapCache =
/*#__PURE__*/
function () {
function FlatMapCache() {
classCallCheck(this, FlatMapCache);
this._cache = new Map();
}
FlatMapCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FlatMapCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);
};
FlatMapCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache.get(key);
};
FlatMapCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._cache.delete(key);
};
FlatMapCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache.clear();

@@ -196,9 +206,9 @@ };

var FifoMapCache = function () {
function FifoMapCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var FifoMapCache =
/*#__PURE__*/
function () {
function FifoMapCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, FifoMapCache);
validateCacheSize(cacheSize);

@@ -209,3 +219,5 @@ this._cache = new Map();

FifoMapCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FifoMapCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);

@@ -215,2 +227,3 @@

var earliest = this._cache.keys().next().value;
this.remove(earliest);

@@ -220,11 +233,11 @@ }

FifoMapCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache.get(key);
};
FifoMapCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._cache.delete(key);
};
FifoMapCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache.clear();

@@ -236,9 +249,9 @@ };

var LruMapCache = function () {
function LruMapCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var LruMapCache =
/*#__PURE__*/
function () {
function LruMapCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, LruMapCache);
validateCacheSize(cacheSize);

@@ -249,3 +262,5 @@ this._cache = new Map();

LruMapCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = LruMapCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);

@@ -255,2 +270,3 @@

var earliest = this._cache.keys().next().value;
this.remove(earliest);

@@ -260,18 +276,20 @@ }

LruMapCache.prototype.get = function get$$1(key) {
var value = this._cache.get(key);
_proto.get = function get(key) {
var value = this._cache.get(key); // Register cache hit
// Register cache hit
if (this._cache.has(key)) {
this.remove(key);
this._cache.set(key, value);
}
return value;
};
LruMapCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._cache.delete(key);
};
LruMapCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache.clear();

@@ -284,2 +302,3 @@ };

var defaultCacheCreator = FlatObjectCache;
var defaultCacheKeyValidator = function defaultCacheKeyValidator() {

@@ -290,8 +309,10 @@ return true;

function createCachedSelector() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
return function (resolver) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return function (resolver, options) {
if (options === void 0) {
options = {};
}

@@ -305,7 +326,6 @@ // @NOTE Versions 0.x/1.x accepted "options" as a function

var selectorCreator = options.selectorCreator || createSelector;
var isValidCacheKey = cache.isValidCacheKey || defaultCacheKeyValidator;
var isValidCacheKey = cache.isValidCacheKey || defaultCacheKeyValidator; // Application receives this function
// Application receives this function
var selector = function selector() {
var cacheKey = resolver.apply(undefined, arguments);
var cacheKey = resolver.apply(void 0, arguments);

@@ -316,16 +336,17 @@ if (isValidCacheKey(cacheKey)) {

if (cacheResponse === undefined) {
cacheResponse = selectorCreator.apply(undefined, funcs);
cacheResponse = selectorCreator.apply(void 0, funcs);
cache.set(cacheKey, cacheResponse);
}
return cacheResponse.apply(undefined, arguments);
return cacheResponse.apply(void 0, arguments);
}
console.warn('[re-reselect] Invalid cache key "' + cacheKey + '" has been returned by resolver function.');
console.warn("[re-reselect] Invalid cache key \"" + cacheKey + "\" has been returned by resolver function.");
return undefined;
};
}; // Further selector methods
// Further selector methods
selector.getMatchingSelector = function () {
var cacheKey = resolver.apply(undefined, arguments);
// @NOTE It might update cache hit count in LRU-like caches
var cacheKey = resolver.apply(void 0, arguments); // @NOTE It might update cache hit count in LRU-like caches
return cache.get(cacheKey);

@@ -335,3 +356,3 @@ };

selector.removeMatchingSelector = function () {
var cacheKey = resolver.apply(undefined, arguments);
var cacheKey = resolver.apply(void 0, arguments);
cache.remove(cacheKey);

@@ -345,5 +366,3 @@ };

selector.resultFunc = funcs[funcs.length - 1];
selector.cache = cache;
return selector;

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

@@ -11,32 +11,28 @@ 'use strict';

var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var FlatObjectCache = function () {
var FlatObjectCache =
/*#__PURE__*/
function () {
function FlatObjectCache() {
classCallCheck(this, FlatObjectCache);
this._cache = {};
}
FlatObjectCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FlatObjectCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
};
FlatObjectCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache[key];
};
FlatObjectCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
delete this._cache[key];
};
FlatObjectCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache = {};
};
FlatObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);

@@ -52,2 +48,3 @@ };

}
if (!Number.isInteger(cacheSize) || cacheSize <= 0) {

@@ -58,9 +55,9 @@ throw new Error('The "cacheSize" property must be a positive integer value.');

var FifoObjectCache = function () {
function FifoObjectCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var FifoObjectCache =
/*#__PURE__*/
function () {
function FifoObjectCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, FifoObjectCache);
validateCacheSize(cacheSize);

@@ -72,4 +69,7 @@ this._cache = {};

FifoObjectCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FifoObjectCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
this._cacheOrdering.push(key);

@@ -83,7 +83,7 @@

FifoObjectCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache[key];
};
FifoObjectCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
var index = this._cacheOrdering.indexOf(key);

@@ -94,6 +94,7 @@

}
delete this._cache[key];
};
FifoObjectCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache = {};

@@ -103,3 +104,3 @@ this._cacheOrdering = [];

FifoObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);

@@ -111,9 +112,9 @@ };

var LruObjectCache = function () {
function LruObjectCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var LruObjectCache =
/*#__PURE__*/
function () {
function LruObjectCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, LruObjectCache);
validateCacheSize(cacheSize);

@@ -125,4 +126,7 @@ this._cache = {};

LruObjectCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = LruObjectCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache[key] = selectorFn;
this._registerCacheHit(key);

@@ -136,13 +140,15 @@

LruObjectCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
this._registerCacheHit(key);
return this._cache[key];
};
LruObjectCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._deleteCacheHit(key);
delete this._cache[key];
};
LruObjectCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache = {};

@@ -152,9 +158,11 @@ this._cacheOrdering = [];

LruObjectCache.prototype._registerCacheHit = function _registerCacheHit(key) {
_proto._registerCacheHit = function _registerCacheHit(key) {
this._deleteCacheHit(key);
this._cacheOrdering.push(key);
};
LruObjectCache.prototype._deleteCacheHit = function _deleteCacheHit(key) {
_proto._deleteCacheHit = function _deleteCacheHit(key) {
var index = this._cacheOrdering.indexOf(key);
if (index > -1) {

@@ -165,3 +173,3 @@ this._cacheOrdering.splice(index, 1);

LruObjectCache.prototype.isValidCacheKey = function isValidCacheKey(cacheKey) {
_proto.isValidCacheKey = function isValidCacheKey(cacheKey) {
return isStringOrNumber(cacheKey);

@@ -173,22 +181,24 @@ };

var FlatMapCache = function () {
var FlatMapCache =
/*#__PURE__*/
function () {
function FlatMapCache() {
classCallCheck(this, FlatMapCache);
this._cache = new Map();
}
FlatMapCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FlatMapCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);
};
FlatMapCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache.get(key);
};
FlatMapCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._cache.delete(key);
};
FlatMapCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache.clear();

@@ -200,9 +210,9 @@ };

var FifoMapCache = function () {
function FifoMapCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var FifoMapCache =
/*#__PURE__*/
function () {
function FifoMapCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, FifoMapCache);
validateCacheSize(cacheSize);

@@ -213,3 +223,5 @@ this._cache = new Map();

FifoMapCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = FifoMapCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);

@@ -219,2 +231,3 @@

var earliest = this._cache.keys().next().value;
this.remove(earliest);

@@ -224,11 +237,11 @@ }

FifoMapCache.prototype.get = function get$$1(key) {
_proto.get = function get(key) {
return this._cache.get(key);
};
FifoMapCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._cache.delete(key);
};
FifoMapCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache.clear();

@@ -240,9 +253,9 @@ };

var LruMapCache = function () {
function LruMapCache() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
var LruMapCache =
/*#__PURE__*/
function () {
function LruMapCache(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
cacheSize = _ref.cacheSize;
classCallCheck(this, LruMapCache);
validateCacheSize(cacheSize);

@@ -253,3 +266,5 @@ this._cache = new Map();

LruMapCache.prototype.set = function set$$1(key, selectorFn) {
var _proto = LruMapCache.prototype;
_proto.set = function set(key, selectorFn) {
this._cache.set(key, selectorFn);

@@ -259,2 +274,3 @@

var earliest = this._cache.keys().next().value;
this.remove(earliest);

@@ -264,18 +280,20 @@ }

LruMapCache.prototype.get = function get$$1(key) {
var value = this._cache.get(key);
_proto.get = function get(key) {
var value = this._cache.get(key); // Register cache hit
// Register cache hit
if (this._cache.has(key)) {
this.remove(key);
this._cache.set(key, value);
}
return value;
};
LruMapCache.prototype.remove = function remove(key) {
_proto.remove = function remove(key) {
this._cache.delete(key);
};
LruMapCache.prototype.clear = function clear() {
_proto.clear = function clear() {
this._cache.clear();

@@ -288,2 +306,3 @@ };

var defaultCacheCreator = FlatObjectCache;
var defaultCacheKeyValidator = function defaultCacheKeyValidator() {

@@ -294,8 +313,10 @@ return true;

function createCachedSelector() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
return function (resolver) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return function (resolver, options) {
if (options === void 0) {
options = {};
}

@@ -309,7 +330,6 @@ // @NOTE Versions 0.x/1.x accepted "options" as a function

var selectorCreator = options.selectorCreator || reselect.createSelector;
var isValidCacheKey = cache.isValidCacheKey || defaultCacheKeyValidator;
var isValidCacheKey = cache.isValidCacheKey || defaultCacheKeyValidator; // Application receives this function
// Application receives this function
var selector = function selector() {
var cacheKey = resolver.apply(undefined, arguments);
var cacheKey = resolver.apply(void 0, arguments);

@@ -320,16 +340,17 @@ if (isValidCacheKey(cacheKey)) {

if (cacheResponse === undefined) {
cacheResponse = selectorCreator.apply(undefined, funcs);
cacheResponse = selectorCreator.apply(void 0, funcs);
cache.set(cacheKey, cacheResponse);
}
return cacheResponse.apply(undefined, arguments);
return cacheResponse.apply(void 0, arguments);
}
console.warn('[re-reselect] Invalid cache key "' + cacheKey + '" has been returned by resolver function.');
console.warn("[re-reselect] Invalid cache key \"" + cacheKey + "\" has been returned by resolver function.");
return undefined;
};
}; // Further selector methods
// Further selector methods
selector.getMatchingSelector = function () {
var cacheKey = resolver.apply(undefined, arguments);
// @NOTE It might update cache hit count in LRU-like caches
var cacheKey = resolver.apply(void 0, arguments); // @NOTE It might update cache hit count in LRU-like caches
return cache.get(cacheKey);

@@ -339,3 +360,3 @@ };

selector.removeMatchingSelector = function () {
var cacheKey = resolver.apply(undefined, arguments);
var cacheKey = resolver.apply(void 0, arguments);
cache.remove(cacheKey);

@@ -349,5 +370,3 @@ };

selector.resultFunc = funcs[funcs.length - 1];
selector.cache = cache;
return selector;

@@ -354,0 +373,0 @@ };

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

@@ -17,17 +17,20 @@ "main": "lib/index.js",

"scripts": {
"test": "npm run test:typescript && npm run test:js -- --coverage",
"test:js": "jest",
"test:typescript": "typings-tester --dir typescript_test",
"test": "npm run test:typescript && jest",
"test:typescript": "typings-tester --config typescript_test/tsconfig.json --dir typescript_test",
"test:bundles": "jest --config ./jest/es.config.js && jest --config ./jest/lib.config.js && jest --config ./jest/dist.config.js",
"clean": "rimraf dist es lib",
"compile": "npm run clean && cross-env BABEL_ENV=rollup rollup -c",
"compile": "npm run clean && rollup -c",
"contrib:add": "all-contributors add",
"contrib:generate": "all-contributors generate",
"preversion": "npm test",
"preversion": "npm run prepublish",
"version": "git add package.json",
"postversion": "git push && git push --tags",
"prepublish": "npm test && npm run compile",
"precommit": "lint-staged",
"prettier": "prettier --write",
"format": "npm run prettier \"{,{examples,src,typescript_test}/**/}*.{js,ts,md}\""
"prepublish": "npm test -- --coverage && npm run compile && npm run test:bundles",
"format": "prettier --write \"**/*.{js,ts,json,md}\""
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"keywords": [

@@ -37,3 +40,4 @@ "react",

"reselect",
"memoize"
"memoize",
"cache"
],

@@ -50,18 +54,16 @@ "repository": {

"devDependencies": {
"all-contributors-cli": "^4.11.1",
"babel-core": "^6.23.1",
"babel-jest": "^22.4.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-register": "^6.23.0",
"coveralls": "^3.0.1",
"cross-env": "^5.0.5",
"husky": "^0.14.3",
"jest": "^22.4.3",
"lint-staged": "^4.0.3",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"all-contributors-cli": "^5.4.1",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"coveralls": "^3.0.2",
"husky": "^1.1.2",
"jest": "^23.6.0",
"lint-staged": "^7.3.0",
"prettier": "^1.11.1",
"reselect": ">1.0.0",
"rimraf": "^2.6.1",
"rollup": "^0.56.5",
"rollup-plugin-babel": "^3.0.3",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.3",
"typescript": "^2.7.2",

@@ -80,3 +82,14 @@ "typings-tester": "^0.2.2"

},
"sideEffects": false
"sideEffects": false,
"lint-staged": {
"**/*.{js,ts}": [
"prettier --write",
"npm t -- .",
"git add"
],
"**/*.md": [
"prettier --write",
"git add"
]
}
}

@@ -66,3 +66,3 @@ # Re-reselect

* [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-cache-key)
* [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)

@@ -73,3 +73,3 @@ * [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)

* [API](#api)
* [`reReselect`](#rereselectreselects-createselector-argumentsresolverfunction-selectorcreator--selectorcreator)
* [`reReselect`](#rereselectreselects-createselector-argumentsresolverfunction--cacheobject-selectorcreator-)
* [reReselectInstance`()`](#rereselectinstanceselectorarguments)

@@ -413,6 +413,7 @@ * [reReselectInstance`.getMatchingSelector`](#rereselectinstancegetmatchingselectorselectorarguments)

| [<img src="https://avatars3.githubusercontent.com/u/4573549?v=4" width="100px;"/><br /><sub>Andrea Carraro</sub>](http://www.andreacarraro.it)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=toomuchdesign 'Code') [📖](https://github.com/toomuchdesign/re-reselect/commits?author=toomuchdesign 'Documentation') [🚇](#infra-toomuchdesign 'Infrastructure (Hosting, Build-Tools, etc)') [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=toomuchdesign 'Tests') [👀](#review-toomuchdesign 'Reviewed Pull Requests') | [<img src="https://avatars2.githubusercontent.com/u/830824?v=4" width="100px;"/><br /><sub>Stepan Burguchev</sub>](https://github.com/xsburg)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=xsburg 'Code') [👀](#review-xsburg 'Reviewed Pull Requests') [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=xsburg 'Tests') | [<img src="https://avatars3.githubusercontent.com/u/693493?v=4" width="100px;"/><br /><sub>Mitch Robb</sub>](https://olslash.github.io/)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=olslash 'Code') [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=olslash 'Tests') | [<img src="https://avatars3.githubusercontent.com/u/1128559?v=4" width="100px;"/><br /><sub>Stephane Rufer</sub>](https://github.com/rufman)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=rufman 'Code') [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=rufman 'Tests') | [<img src="https://avatars0.githubusercontent.com/u/2788860?v=4" width="100px;"/><br /><sub>Tracy Mullen</sub>](https://github.com/spiffysparrow)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=spiffysparrow 'Code') [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=spiffysparrow 'Tests') | [<img src="https://avatars1.githubusercontent.com/u/4211838?v=4" width="100px;"/><br /><sub>Sushain Cherivirala</sub>](https://www.skc.name)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=sushain97 'Code') | [<img src="https://avatars0.githubusercontent.com/u/6316590?v=4" width="100px;"/><br /><sub>Steve Mao</sub>](https://twitter.com/MaoStevemao)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=stevemao 'Documentation') |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| [<img src="https://avatars2.githubusercontent.com/u/1428826?v=4" width="100px;"/><br /><sub>Gaurav Lahoti</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>Lon</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>bratushka</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>Anders D. Johnson</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>Július Retzer</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>Maarten Schumacher</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>Alexander Jarvis</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>Gregg B</sub>](https://github.com/greggb)<br />[💡](#example-greggb 'Examples') | [<img src="https://avatars0.githubusercontent.com/u/897931?v=4" width="100px;"/><br /><sub>Ian Obermiller</sub>](http://ianobermiller.com)<br />[👀](#review-ianobermiller 'Reviewed Pull Requests') |
<!-- prettier-ignore -->
| [<img src="https://avatars3.githubusercontent.com/u/4573549?v=4" width="100px;"/><br /><sub><b>Andrea Carraro</b></sub>](http://www.andreacarraro.it)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=toomuchdesign "Code") [📖](https://github.com/toomuchdesign/re-reselect/commits?author=toomuchdesign "Documentation") [🚇](#infra-toomuchdesign "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=toomuchdesign "Tests") [👀](#review-toomuchdesign "Reviewed Pull Requests") | [<img src="https://avatars2.githubusercontent.com/u/830824?v=4" width="100px;"/><br /><sub><b>Stepan Burguchev</b></sub>](https://github.com/xsburg)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=xsburg "Code") [👀](#review-xsburg "Reviewed Pull Requests") [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=xsburg "Tests") | [<img src="https://avatars3.githubusercontent.com/u/693493?v=4" width="100px;"/><br /><sub><b>Mitch Robb</b></sub>](https://olslash.github.io/)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=olslash "Code") [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=olslash "Tests") | [<img src="https://avatars3.githubusercontent.com/u/1128559?v=4" width="100px;"/><br /><sub><b>Stephane Rufer</b></sub>](https://github.com/rufman)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=rufman "Code") [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=rufman "Tests") | [<img src="https://avatars0.githubusercontent.com/u/2788860?v=4" width="100px;"/><br /><sub><b>Tracy Mullen</b></sub>](https://github.com/spiffysparrow)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=spiffysparrow "Code") [⚠️](https://github.com/toomuchdesign/re-reselect/commits?author=spiffysparrow "Tests") | [<img src="https://avatars1.githubusercontent.com/u/4211838?v=4" width="100px;"/><br /><sub><b>Sushain Cherivirala</b></sub>](https://www.skc.name)<br />[💻](https://github.com/toomuchdesign/re-reselect/commits?author=sushain97 "Code") | [<img src="https://avatars0.githubusercontent.com/u/6316590?v=4" width="100px;"/><br /><sub><b>Steve Mao</b></sub>](https://twitter.com/MaoStevemao)<br />[📖](https://github.com/toomuchdesign/re-reselect/commits?author=stevemao "Documentation") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<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") |

@@ -419,0 +420,0 @@ <!-- ALL-CONTRIBUTORS-LIST:END -->

/* eslint comma-dangle: 0 */
import {createSelector} from 'reselect';
import createCachedSelector, {FlatObjectCache} from '../index';
import createCachedSelector, {FlatObjectCache} from '../../src/index';

@@ -5,0 +5,0 @@ let resultFunc;

@@ -1,2 +0,2 @@

import {FifoCacheObject as CacheObject} from '../../../index';
import {FifoCacheObject as CacheObject} from '../../../../src/index';

@@ -3,0 +3,0 @@ describe('FifoCacheObject (deprecated)', () => {

@@ -1,2 +0,2 @@

import {FlatCacheObject as CacheObject} from '../../../index';
import {FlatCacheObject as CacheObject} from '../../../../src/index';

@@ -3,0 +3,0 @@ describe('FlatCacheObject (deprecated)', () => {

@@ -1,2 +0,2 @@

import {LruCacheObject as CacheObject} from '../../../index';
import {LruCacheObject as CacheObject} from '../../../../src/index';

@@ -3,0 +3,0 @@ describe('LruCacheObject (deprecated)', () => {

@@ -1,2 +0,2 @@

import {FifoMapCache as CacheObject} from '../../index';
import {FifoMapCache as CacheObject} from '../../../src/index';
import testFifoBehavior from '../__util__/testFifoBehavior';

@@ -3,0 +3,0 @@ import testBasicBehavior from '../__util__/testBasicBehavior';

@@ -1,2 +0,2 @@

import {FifoObjectCache as CacheObject} from '../../index';
import {FifoObjectCache as CacheObject} from '../../../src/index';
import testBasicBehavior from '../__util__/testBasicBehavior';

@@ -3,0 +3,0 @@ import testFifoBehavior from '../__util__/testFifoBehavior';

@@ -1,2 +0,2 @@

import {FlatMapCache as CacheObject} from '../../index';
import {FlatMapCache as CacheObject} from '../../../src/index';
import testBasicBehavior from '../__util__/testBasicBehavior';

@@ -3,0 +3,0 @@ import testMapCacheKeyBehavior from '../__util__/testMapCacheKeyBehavior';

@@ -1,2 +0,2 @@

import {FlatObjectCache as CacheObject} from '../../index';
import {FlatObjectCache as CacheObject} from '../../../src/index';
import testBasicBehavior from '../__util__/testBasicBehavior';

@@ -3,0 +3,0 @@ import testObjectCacheKeyBehavior from '../__util__/testObjectCacheKeyBehavior';

@@ -1,2 +0,2 @@

import {LruMapCache as CacheObject} from '../../index';
import {LruMapCache as CacheObject} from '../../../src/index';
import testBasicBehavior from '../__util__/testBasicBehavior';

@@ -3,0 +3,0 @@ import testLruBehavior from '../__util__/testLruBehavior';

@@ -1,2 +0,2 @@

import {LruObjectCache as CacheObject} from '../../index';
import {LruObjectCache as CacheObject} from '../../../src/index';
import testBasicBehavior from '../__util__/testBasicBehavior';

@@ -3,0 +3,0 @@ import testLruBehavior from '../__util__/testLruBehavior';

@@ -1537,11 +1537,13 @@ import {createSelector} from 'reselect';

clear(): void;
isValidCacheKey?(): boolean;
isValidCacheKey?(key: any): boolean;
}
type ObjectCacheKey = string | number;
export class FlatObjectCache implements ICacheObject {
set(key: string | number, selectorFn: any): void;
get(key: string | number): any;
remove(key: string | number): void;
set(key: ObjectCacheKey, selectorFn: any): void;
get(key: ObjectCacheKey): any;
remove(key: ObjectCacheKey): void;
clear(): void;
isValidCacheKey(): boolean;
isValidCacheKey(key: ObjectCacheKey): boolean;
}

@@ -1551,7 +1553,7 @@

constructor(options: {cacheSize: number});
set(key: string | number, selectorFn: any): void;
get(key: string | number): any;
remove(key: string | number): void;
set(key: ObjectCacheKey, selectorFn: any): void;
get(key: ObjectCacheKey): any;
remove(key: ObjectCacheKey): void;
clear(): void;
isValidCacheKey(): boolean;
isValidCacheKey(key: ObjectCacheKey): boolean;
}

@@ -1561,7 +1563,7 @@

constructor(options: {cacheSize: number});
set(key: string | number, selectorFn: any): void;
get(key: string | number): any;
remove(key: string | number): void;
set(key: ObjectCacheKey, selectorFn: any): void;
get(key: ObjectCacheKey): any;
remove(key: ObjectCacheKey): void;
clear(): void;
isValidCacheKey(): boolean;
isValidCacheKey(key: ObjectCacheKey): boolean;
}

@@ -1568,0 +1570,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