Comparing version 1.0.0 to 1.0.1
@@ -15,3 +15,4 @@ import { isWeakable } from "./utils"; | ||
if (test_1) { | ||
if (test_1.arguments.every(function (v, index) { return v === args[index]; })) { | ||
if (test_1.arguments.length === max && | ||
test_1.arguments.every(function (v, index) { return v === args[index]; })) { | ||
return { | ||
@@ -27,3 +28,3 @@ value: test_1.storedValue, | ||
console.log('arguments given', args); | ||
throw new Error('No weak-mappable object found to read a result from'); | ||
throw new Error('No weak-mappable object found to read a cache from. Given [' + args.map(function (a) { return typeof a; }).join(', ') + ']'); | ||
} | ||
@@ -30,0 +31,0 @@ return undefined; |
@@ -14,11 +14,13 @@ import { isWeakable } from "./utils"; | ||
var a = test.arguments; | ||
for (var i = 0; i < a.length; ++i) { | ||
if (a[i] !== args[i]) { | ||
return undefined; | ||
if (a.length === args.length) { | ||
for (var i = 0; i < a.length; ++i) { | ||
if (a[i] !== args[i]) { | ||
return undefined; | ||
} | ||
} | ||
return { | ||
value: test.storedValue, | ||
index: indexId, | ||
}; | ||
} | ||
return { | ||
value: test.storedValue, | ||
index: indexId, | ||
}; | ||
} | ||
@@ -25,0 +27,0 @@ return undefined; |
@@ -17,3 +17,4 @@ "use strict"; | ||
if (test_1) { | ||
if (test_1.arguments.every(function (v, index) { return v === args[index]; })) { | ||
if (test_1.arguments.length === max && | ||
test_1.arguments.every(function (v, index) { return v === args[index]; })) { | ||
return { | ||
@@ -29,3 +30,3 @@ value: test_1.storedValue, | ||
console.log('arguments given', args); | ||
throw new Error('No weak-mappable object found to read a result from'); | ||
throw new Error('No weak-mappable object found to read a cache from. Given [' + args.map(function (a) { return typeof a; }).join(', ') + ']'); | ||
} | ||
@@ -32,0 +33,0 @@ return undefined; |
@@ -16,11 +16,13 @@ "use strict"; | ||
var a = test.arguments; | ||
for (var i = 0; i < a.length; ++i) { | ||
if (a[i] !== args[i]) { | ||
return undefined; | ||
if (a.length === args.length) { | ||
for (var i = 0; i < a.length; ++i) { | ||
if (a[i] !== args[i]) { | ||
return undefined; | ||
} | ||
} | ||
return { | ||
value: test.storedValue, | ||
index: indexId, | ||
}; | ||
} | ||
return { | ||
value: test.storedValue, | ||
index: indexId, | ||
}; | ||
} | ||
@@ -27,0 +29,0 @@ return undefined; |
{ | ||
"name": "kashe", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Stateless memoization replacement for reselect and memoize-one", | ||
@@ -5,0 +5,0 @@ "main": "dist/es5/index.js", |
@@ -243,2 +243,16 @@ <div align="center"> | ||
## Troubleshoting | ||
#### solving `Error: No weak-mappable object found to read a cache from.` | ||
If all selectors returned a non "weak-mappable" object (like array, object, function, symbol) - kashe would throw. | ||
This is intentional, as long as it stores cache inside such objects, and without them it could not work. | ||
However, if you think that it should work that way - just give it that "cache" | ||
```js | ||
const cache = {}; | ||
const selector = createSelector( | ||
someSelector, | ||
() => cache, // <---- cache for a selector | ||
selectedData => {/*...*/} | ||
); | ||
``` | ||
# Memoize-one | ||
@@ -245,0 +259,0 @@ `kashe` could not replace `memoize-one` as long as it requires at least one argument to be a object or array. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39777
613
344