Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kashe

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kashe - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

5

dist/es2015/strongStorage.js

@@ -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;

16

dist/es2015/weakStorage.js

@@ -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.

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