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

nano-memoize

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano-memoize - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

69

browser/nano-memoize.js
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function() {
"use strict"
"use strict";
var assign = Object.assign;

@@ -10,14 +10,14 @@ if(typeof(assign)!=="function") {

if (o === null || o === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
throw new TypeError("Cannot convert undefined or null to object");
}
o = Object(o);
for(var i=1;i<a.length;i++) {
if(a[i] && typeof(a[i])==="object") {
Object.keys(a[i]).forEach(function(k) {
for(var k in a[i]) {
o[k] = a[i][k];
})
}
}
}
return o;
}
};
}

@@ -46,8 +46,8 @@ var vrgs = function f() {

if(k) { // dealing with multi-arg function, c and k are Arrays
c.splice(key,1);
c.splice (key,1);
k.splice(key,1);
return;
} // dealing with single arg function, c is a WekMap or Object
c instanceof WeakMap ? c.delete(key) : delete c[key]
},o.maxAge)},
c instanceof WeakMap ? c.delete(key) : delete c[key];
},o.maxAge); },
c = o.maxAge>0 && o.maxAge<Infinity ? d : 0, // cache change timeout,

@@ -59,24 +59,25 @@ eq = o.equals ? o.equals : function(a,b) { return a===b; },

u; // flag indicating a unary arg function is in use for clear operation
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
// for multiple arg functions, loop through a cache of all the args
// looking at each arg separately so a test can abort as soon as possible
f = (function() {
var l = maxargs||arguments.length;
for(var i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
var l = maxargs||arguments.length,
i;
for(i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
for(var j=l-1;j>=0 && eq(k[i][j],arguments[j]);j--) { // compare each arg
if(j===0) return v[i]; // the args matched
if(j===0) { return v[i]; } // the args matched
}

@@ -92,13 +93,13 @@ }

wm = new WeakMap();
s = Object.create(null)
s = Object.create(null);
k = [];
v = [];
};
f.keys = function() { return u ? null : k.slice() };
f.values = function() { return u ? null : v.slice() };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null };
f.keys = function() { return u ? null : k.slice(); };
f.values = function() { return u ? null : v.slice(); };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null; };
return f;
}
if(typeof(module)!=="undefined") module.exports = nanomemoize;
if(typeof(window)!=="undefined") window.nanomemoize = nanomemoize;
};
if(typeof(module)!=="undefined") { module.exports = nanomemoize; }
if(typeof(window)!=="undefined") { window.nanomemoize = nanomemoize; }
}).call(this);

@@ -105,0 +106,0 @@

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

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){(function(){"use strict";var assign=Object.assign;if(typeof assign!=="function"){assign=function(){var a=arguments,o=arguments[0];if(o===null||o===undefined){throw new TypeError("Cannot convert undefined or null to object")}o=Object(o);for(var i=1;i<a.length;i++){if(a[i]&&typeof a[i]==="object"){Object.keys(a[i]).forEach(function(k){o[k]=a[i][k]})}}return o}}var vrgs=function f(){var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=function(fn,o){o||(o={});var vargs=o.vargs||vrgs(fn),s=Object.create(null),k=[],v=[],wm=new WeakMap,d=function(key,c,k){return setTimeout(function(){if(k){c.splice(key,1);k.splice(key,1);return}c instanceof WeakMap?c.delete(key):delete c[key]},o.maxAge)},c=o.maxAge>0&&o.maxAge<Infinity?d:0,eq=o.equals?o.equals:function(a,b){return a===b},maxargs=o.maxArgs,srlz=o.serializer,f,u;if(fn.length===1&&!o.equals&&!vargs){f=function(a){var t=typeof a;if(!srlz&&(t==="object"||t==="function")){var r;return wm.get(a)||(!c||c(a,wm),wm.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(a):srlz(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this);u=1}else{f=function(){var l=maxargs||arguments.length;for(var i=k.length-1;i>=0;i--){for(var j=l-1;j>=0&&eq(k[i][j],arguments[j]);j--){if(j===0)return v[i]}}i=k.length-(i+1);return!c||c(i,v,k),v[i]=fn.apply(this,k[i]=arguments)}.bind(this)}f.clear=function(){wm=new WeakMap;s=Object.create(null);k=[];v=[]};f.keys=function(){return u?null:k.slice()};f.values=function(){return u?null:v.slice()};f.keyValues=function(){return u?{primitives:assign({},s),objects:wm}:null};return f};if(typeof module!=="undefined")module.exports=nanomemoize;if(typeof window!=="undefined")window.nanomemoize=nanomemoize}).call(this)},{}]},{},[1]);
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){(function(){"use strict";var assign=Object.assign;if(typeof assign!=="function"){assign=function(){var a=arguments,o=arguments[0];if(o===null||o===undefined){throw new TypeError("Cannot convert undefined or null to object")}o=Object(o);for(var i=1;i<a.length;i++){if(a[i]&&typeof a[i]==="object"){for(var k in a[i]){o[k]=a[i][k]}}}return o}}var vrgs=function f(){var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=function(fn,o){o||(o={});var vargs=o.vargs||vrgs(fn),s=Object.create(null),k=[],v=[],wm=new WeakMap,d=function(key,c,k){return setTimeout(function(){if(k){c.splice(key,1);k.splice(key,1);return}c instanceof WeakMap?c.delete(key):delete c[key]},o.maxAge)},c=o.maxAge>0&&o.maxAge<Infinity?d:0,eq=o.equals?o.equals:function(a,b){return a===b},maxargs=o.maxArgs,srlz=o.serializer,f,u;if(fn.length===1&&!o.equals&&!vargs){f=function(a){var t=typeof a;if(!srlz&&(t==="object"||t==="function")){var r;return wm.get(a)||(!c||c(a,wm),wm.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(a):srlz(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this);u=1}else{f=function(){var l=maxargs||arguments.length,i;for(i=k.length-1;i>=0;i--){for(var j=l-1;j>=0&&eq(k[i][j],arguments[j]);j--){if(j===0){return v[i]}}}i=k.length-(i+1);return!c||c(i,v,k),v[i]=fn.apply(this,k[i]=arguments)}.bind(this)}f.clear=function(){wm=new WeakMap;s=Object.create(null);k=[];v=[]};f.keys=function(){return u?null:k.slice()};f.values=function(){return u?null:v.slice()};f.keyValues=function(){return u?{primitives:assign({},s),objects:wm}:null};return f};if(typeof module!=="undefined"){module.exports=nanomemoize}if(typeof window!=="undefined"){window.nanomemoize=nanomemoize}}).call(this)},{}]},{},[1]);
(function() {
"use strict"
"use strict";
var assign = Object.assign;

@@ -9,14 +9,14 @@ if(typeof(assign)!=="function") {

if (o === null || o === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
throw new TypeError("Cannot convert undefined or null to object");
}
o = Object(o);
for(var i=1;i<a.length;i++) {
if(a[i] && typeof(a[i])==="object") {
Object.keys(a[i]).forEach(function(k) {
for(var k in a[i]) {
o[k] = a[i][k];
})
}
}
}
return o;
}
};
}

@@ -45,8 +45,8 @@ var vrgs = function f() {

if(k) { // dealing with multi-arg function, c and k are Arrays
c.splice(key,1);
c.splice (key,1);
k.splice(key,1);
return;
} // dealing with single arg function, c is a WekMap or Object
c instanceof WeakMap ? c.delete(key) : delete c[key]
},o.maxAge)},
c instanceof WeakMap ? c.delete(key) : delete c[key];
},o.maxAge); },
c = o.maxAge>0 && o.maxAge<Infinity ? d : 0, // cache change timeout,

@@ -58,24 +58,25 @@ eq = o.equals ? o.equals : function(a,b) { return a===b; },

u; // flag indicating a unary arg function is in use for clear operation
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
// for multiple arg functions, loop through a cache of all the args
// looking at each arg separately so a test can abort as soon as possible
f = (function() {
var l = maxargs||arguments.length;
for(var i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
var l = maxargs||arguments.length,
i;
for(i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
for(var j=l-1;j>=0 && eq(k[i][j],arguments[j]);j--) { // compare each arg
if(j===0) return v[i]; // the args matched
if(j===0) { return v[i]; } // the args matched
}

@@ -91,14 +92,14 @@ }

wm = new WeakMap();
s = Object.create(null)
s = Object.create(null);
k = [];
v = [];
};
f.keys = function() { return u ? null : k.slice() };
f.values = function() { return u ? null : v.slice() };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null };
f.keys = function() { return u ? null : k.slice(); };
f.values = function() { return u ? null : v.slice(); };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null; };
return f;
}
if(typeof(module)!=="undefined") module.exports = nanomemoize;
if(typeof(window)!=="undefined") window.nanomemoize = nanomemoize;
};
if(typeof(module)!=="undefined") { module.exports = nanomemoize; }
if(typeof(window)!=="undefined") { window.nanomemoize = nanomemoize; }
}).call(this);

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

(function(){"use strict";var assign=Object.assign;if(typeof assign!=="function"){assign=function(){var a=arguments,o=arguments[0];if(o===null||o===undefined){throw new TypeError("Cannot convert undefined or null to object")}o=Object(o);for(var i=1;i<a.length;i++){if(a[i]&&typeof a[i]==="object"){Object.keys(a[i]).forEach(function(k){o[k]=a[i][k]})}}return o}}var vrgs=function f(){var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=function(fn,o){o||(o={});var vargs=o.vargs||vrgs(fn),s=Object.create(null),k=[],v=[],wm=new WeakMap,d=function(key,c,k){return setTimeout(function(){if(k){c.splice(key,1);k.splice(key,1);return}c instanceof WeakMap?c.delete(key):delete c[key]},o.maxAge)},c=o.maxAge>0&&o.maxAge<Infinity?d:0,eq=o.equals?o.equals:function(a,b){return a===b},maxargs=o.maxArgs,srlz=o.serializer,f,u;if(fn.length===1&&!o.equals&&!vargs){f=function(a){var t=typeof a;if(!srlz&&(t==="object"||t==="function")){var r;return wm.get(a)||(!c||c(a,wm),wm.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(a):srlz(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this);u=1}else{f=function(){var l=maxargs||arguments.length;for(var i=k.length-1;i>=0;i--){for(var j=l-1;j>=0&&eq(k[i][j],arguments[j]);j--){if(j===0)return v[i]}}i=k.length-(i+1);return!c||c(i,v,k),v[i]=fn.apply(this,k[i]=arguments)}.bind(this)}f.clear=function(){wm=new WeakMap;s=Object.create(null);k=[];v=[]};f.keys=function(){return u?null:k.slice()};f.values=function(){return u?null:v.slice()};f.keyValues=function(){return u?{primitives:assign({},s),objects:wm}:null};return f};if(typeof module!=="undefined")module.exports=nanomemoize;if(typeof window!=="undefined")window.nanomemoize=nanomemoize}).call(this);
(function(){"use strict";var assign=Object.assign;if(typeof assign!=="function"){assign=function(){var a=arguments,o=arguments[0];if(o===null||o===undefined){throw new TypeError("Cannot convert undefined or null to object")}o=Object(o);for(var i=1;i<a.length;i++){if(a[i]&&typeof a[i]==="object"){for(var k in a[i]){o[k]=a[i][k]}}}return o}}var vrgs=function f(){var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=function(fn,o){o||(o={});var vargs=o.vargs||vrgs(fn),s=Object.create(null),k=[],v=[],wm=new WeakMap,d=function(key,c,k){return setTimeout(function(){if(k){c.splice(key,1);k.splice(key,1);return}c instanceof WeakMap?c.delete(key):delete c[key]},o.maxAge)},c=o.maxAge>0&&o.maxAge<Infinity?d:0,eq=o.equals?o.equals:function(a,b){return a===b},maxargs=o.maxArgs,srlz=o.serializer,f,u;if(fn.length===1&&!o.equals&&!vargs){f=function(a){var t=typeof a;if(!srlz&&(t==="object"||t==="function")){var r;return wm.get(a)||(!c||c(a,wm),wm.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(a):srlz(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this);u=1}else{f=function(){var l=maxargs||arguments.length,i;for(i=k.length-1;i>=0;i--){for(var j=l-1;j>=0&&eq(k[i][j],arguments[j]);j--){if(j===0){return v[i]}}}i=k.length-(i+1);return!c||c(i,v,k),v[i]=fn.apply(this,k[i]=arguments)}.bind(this)}f.clear=function(){wm=new WeakMap;s=Object.create(null);k=[];v=[]};f.keys=function(){return u?null:k.slice()};f.values=function(){return u?null:v.slice()};f.keyValues=function(){return u?{primitives:assign({},s),objects:wm}:null};return f};if(typeof module!=="undefined"){module.exports=nanomemoize}if(typeof window!=="undefined"){window.nanomemoize=nanomemoize}}).call(this);
(function() {
"use strict"
"use strict";
var assign = Object.assign;

@@ -9,14 +9,14 @@ if(typeof(assign)!=="function") {

if (o === null || o === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
throw new TypeError("Cannot convert undefined or null to object");
}
o = Object(o);
for(var i=1;i<a.length;i++) {
if(a[i] && typeof(a[i])==="object") {
Object.keys(a[i]).forEach(function(k) {
for(var k in a[i]) {
o[k] = a[i][k];
})
}
}
}
return o;
}
};
}

@@ -45,8 +45,8 @@ var vrgs = function f() {

if(k) { // dealing with multi-arg function, c and k are Arrays
c.splice(key,1);
c.splice (key,1);
k.splice(key,1);
return;
} // dealing with single arg function, c is a WekMap or Object
c instanceof WeakMap ? c.delete(key) : delete c[key]
},o.maxAge)},
c instanceof WeakMap ? c.delete(key) : delete c[key];
},o.maxAge); },
c = o.maxAge>0 && o.maxAge<Infinity ? d : 0, // cache change timeout,

@@ -58,24 +58,25 @@ eq = o.equals ? o.equals : function(a,b) { return a===b; },

u; // flag indicating a unary arg function is in use for clear operation
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
// for multiple arg functions, loop through a cache of all the args
// looking at each arg separately so a test can abort as soon as possible
f = (function() {
var l = maxargs||arguments.length;
for(var i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
var l = maxargs||arguments.length,
i;
for(i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
for(var j=l-1;j>=0 && eq(k[i][j],arguments[j]);j--) { // compare each arg
if(j===0) return v[i]; // the args matched
if(j===0) { return v[i]; } // the args matched
}

@@ -91,14 +92,14 @@ }

wm = new WeakMap();
s = Object.create(null)
s = Object.create(null);
k = [];
v = [];
};
f.keys = function() { return u ? null : k.slice() };
f.values = function() { return u ? null : v.slice() };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null };
f.keys = function() { return u ? null : k.slice(); };
f.values = function() { return u ? null : v.slice(); };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null; };
return f;
}
if(typeof(module)!=="undefined") module.exports = nanomemoize;
if(typeof(window)!=="undefined") window.nanomemoize = nanomemoize;
};
if(typeof(module)!=="undefined") { module.exports = nanomemoize; }
if(typeof(window)!=="undefined") { window.nanomemoize = nanomemoize; }
}).call(this);
{
"name": "nano-memoize",
"version": "v1.1.8",
"version": "v1.1.9",
"description": "Faster than fast, smaller than micro ... a nano speed and nano size memoizer.",

@@ -53,3 +53,5 @@ "engines": {},

},
"dependencies": {}
"dependencies": {
"growl": "^1.10.5"
}
}

@@ -211,2 +211,4 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/30ce201484754fa5b0a6c6046abb842d)](https://www.codacy.com/app/syblackwell/nano-memoize?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=anywhichway/nano-memoize&amp;utm_campaign=Badge_Grade)

2020-01-30 v1.1.9 Code style improvements.
2019-11-29 v1.1.8 Corrected typos in documentation.

@@ -213,0 +215,0 @@

(function() {
"use strict"
"use strict";
var assign = Object.assign;

@@ -9,14 +9,14 @@ if(typeof(assign)!=="function") {

if (o === null || o === undefined) {
throw new TypeError('Cannot convert undefined or null to object');
}
throw new TypeError("Cannot convert undefined or null to object");
}
o = Object(o);
for(var i=1;i<a.length;i++) {
if(a[i] && typeof(a[i])==="object") {
Object.keys(a[i]).forEach(function(k) {
for(var k in a[i]) {
o[k] = a[i][k];
})
}
}
}
return o;
}
};
}

@@ -45,8 +45,8 @@ var vrgs = function f() {

if(k) { // dealing with multi-arg function, c and k are Arrays
c.splice(key,1);
c.splice (key,1);
k.splice(key,1);
return;
} // dealing with single arg function, c is a WekMap or Object
c instanceof WeakMap ? c.delete(key) : delete c[key]
},o.maxAge)},
c instanceof WeakMap ? c.delete(key) : delete c[key];
},o.maxAge); },
c = o.maxAge>0 && o.maxAge<Infinity ? d : 0, // cache change timeout,

@@ -58,24 +58,25 @@ eq = o.equals ? o.equals : function(a,b) { return a===b; },

u; // flag indicating a unary arg function is in use for clear operation
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
if(fn.length===1 && !o.equals && !vargs) {
// for single argument functions, just use a JS object key look-up
f = (function(a) {
// strings must be serialized because cache[1] should not equal or overwrite cache["1"] for value = 1 and value = "1"
var t = typeof a;
// set chng timeout only when new value computed, hits will not push out the tte, but it is arguable they should not
if(!srlz && (t==="object" || t==="function")) {
var r;
return wm.get(a) || ((!c||c(a,wm)),wm.set(a,r = fn.call(this, a)),r);
}
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : srlz(a);
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a));
}).bind(this);
u = 1;
} else {
// for multiple arg functions, loop through a cache of all the args
// looking at each arg separately so a test can abort as soon as possible
f = (function() {
var l = maxargs||arguments.length;
for(var i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
var l = maxargs||arguments.length,
i;
for(i=k.length-1;i>=0;i--) { // an array of arrays of args, each array represents a call signature
for(var j=l-1;j>=0 && eq(k[i][j],arguments[j]);j--) { // compare each arg
if(j===0) return v[i]; // the args matched
if(j===0) { return v[i]; } // the args matched
}

@@ -91,14 +92,14 @@ }

wm = new WeakMap();
s = Object.create(null)
s = Object.create(null);
k = [];
v = [];
};
f.keys = function() { return u ? null : k.slice() };
f.values = function() { return u ? null : v.slice() };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null };
f.keys = function() { return u ? null : k.slice(); };
f.values = function() { return u ? null : v.slice(); };
f.keyValues = function() { return u ? {primitives:assign({},s),objects:wm} : null; };
return f;
}
if(typeof(module)!=="undefined") module.exports = nanomemoize;
if(typeof(window)!=="undefined") window.nanomemoize = nanomemoize;
};
if(typeof(module)!=="undefined") { module.exports = nanomemoize; }
if(typeof(window)!=="undefined") { window.nanomemoize = nanomemoize; }
}).call(this);

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

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