nano-memoize
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -41,3 +41,3 @@ (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){ | ||
} | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(t) : p(a); | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : p(a); | ||
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a)); | ||
@@ -44,0 +44,0 @@ }).bind( |
@@ -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(){var vrgs=f=>{var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=(fn,{serializer:serializer,equals:equals,maxAge:maxAge,maxArgs:maxArgs,vargs:vargs=vrgs(fn)}={})=>{var s=Object.create(null),k=[],v=[],wm={m:new WeakMap},d=(key,c)=>setTimeout(()=>{c instanceof WeakMap?c.delete(key):delete c[key]},maxAge),I=Infinity,f,u;if(fn.length===1&&!equals&&!vargs){f=function(f,s,wm,c,p,a){var t=typeof a;if(!p&&(t==="object"||t==="function")){var r;return wm.m.get(a)||(!c||c(a,wm.m),wm.m.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(t):p(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this,fn,s,wm,maxAge>0&&maxAge<I?d:0,serializer);u=1}else{f=function(f,k,v,e,c,m,...a){var i,j,l=m||a.length;for(i=0;i<k.length&&v[i]!==undefined;i++){for(j=0;j<=l&&(k[i][j]===a[j]||e&&e(k[i][j],a[j]));j++){if(j===l)return v[i]}}!c||c(i,v);return v[i]=fn.apply(this,k[i]=a)}.bind(this,fn,k,v,equals,maxAge>0&&maxAge<I?d:0,maxArgs)}f.clear=(_=>{Object.keys(s).forEach(k=>delete s[k]);wm.m=new WeakMap;k.length=0;v.length=0});f.keys=(_=>u?null:k.slice());f.values=(_=>u?null:v.slice());f.keyValues=(_=>u?{primitives:Object.assign({},s),objects:wm.m}: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(){var vrgs=f=>{var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=(fn,{serializer:serializer,equals:equals,maxAge:maxAge,maxArgs:maxArgs,vargs:vargs=vrgs(fn)}={})=>{var s=Object.create(null),k=[],v=[],wm={m:new WeakMap},d=(key,c)=>setTimeout(()=>{c instanceof WeakMap?c.delete(key):delete c[key]},maxAge),I=Infinity,f,u;if(fn.length===1&&!equals&&!vargs){f=function(f,s,wm,c,p,a){var t=typeof a;if(!p&&(t==="object"||t==="function")){var r;return wm.m.get(a)||(!c||c(a,wm.m),wm.m.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(a):p(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this,fn,s,wm,maxAge>0&&maxAge<I?d:0,serializer);u=1}else{f=function(f,k,v,e,c,m,...a){var i,j,l=m||a.length;for(i=0;i<k.length&&v[i]!==undefined;i++){for(j=0;j<=l&&(k[i][j]===a[j]||e&&e(k[i][j],a[j]));j++){if(j===l)return v[i]}}!c||c(i,v);return v[i]=fn.apply(this,k[i]=a)}.bind(this,fn,k,v,equals,maxAge>0&&maxAge<I?d:0,maxArgs)}f.clear=(_=>{Object.keys(s).forEach(k=>delete s[k]);wm.m=new WeakMap;k.length=0;v.length=0});f.keys=(_=>u?null:k.slice());f.values=(_=>u?null:v.slice());f.keyValues=(_=>u?{primitives:Object.assign({},s),objects:wm.m}:null);return f};if(typeof module!=="undefined")module.exports=nanomemoize;if(typeof window!=="undefined")window.nanomemoize=nanomemoize}).call(this)},{}]},{},[1]); |
@@ -40,3 +40,3 @@ (function() { | ||
} | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(t) : p(a); | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : p(a); | ||
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a)); | ||
@@ -43,0 +43,0 @@ }).bind( |
@@ -1,1 +0,1 @@ | ||
(function(){var vrgs=f=>{var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=(fn,{serializer:serializer,equals:equals,maxAge:maxAge,maxArgs:maxArgs,vargs:vargs=vrgs(fn)}={})=>{var s=Object.create(null),k=[],v=[],wm={m:new WeakMap},d=(key,c)=>setTimeout(()=>{c instanceof WeakMap?c.delete(key):delete c[key]},maxAge),I=Infinity,f,u;if(fn.length===1&&!equals&&!vargs){f=function(f,s,wm,c,p,a){var t=typeof a;if(!p&&(t==="object"||t==="function")){var r;return wm.m.get(a)||(!c||c(a,wm.m),wm.m.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(t):p(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this,fn,s,wm,maxAge>0&&maxAge<I?d:0,serializer);u=1}else{f=function(f,k,v,e,c,m,...a){var i,j,l=m||a.length;for(i=0;i<k.length&&v[i]!==undefined;i++){for(j=0;j<=l&&(k[i][j]===a[j]||e&&e(k[i][j],a[j]));j++){if(j===l)return v[i]}}!c||c(i,v);return v[i]=fn.apply(this,k[i]=a)}.bind(this,fn,k,v,equals,maxAge>0&&maxAge<I?d:0,maxArgs)}f.clear=(_=>{Object.keys(s).forEach(k=>delete s[k]);wm.m=new WeakMap;k.length=0;v.length=0});f.keys=(_=>u?null:k.slice());f.values=(_=>u?null:v.slice());f.keyValues=(_=>u?{primitives:Object.assign({},s),objects:wm.m}:null);return f};if(typeof module!=="undefined")module.exports=nanomemoize;if(typeof window!=="undefined")window.nanomemoize=nanomemoize}).call(this); | ||
(function(){var vrgs=f=>{var s=f+"",i=s.indexOf("...");return i>=0&&i<s.indexOf(")"||s.indexOf("arguments")>=0)},nanomemoize=(fn,{serializer:serializer,equals:equals,maxAge:maxAge,maxArgs:maxArgs,vargs:vargs=vrgs(fn)}={})=>{var s=Object.create(null),k=[],v=[],wm={m:new WeakMap},d=(key,c)=>setTimeout(()=>{c instanceof WeakMap?c.delete(key):delete c[key]},maxAge),I=Infinity,f,u;if(fn.length===1&&!equals&&!vargs){f=function(f,s,wm,c,p,a){var t=typeof a;if(!p&&(t==="object"||t==="function")){var r;return wm.m.get(a)||(!c||c(a,wm.m),wm.m.set(a,r=fn.call(this,a)),r)}var key=t==="number"||t==="boolean"||t==="undefined"?a:t==="string"?JSON.stringify(a):p(a);return s[key]||(!c||c(key,s),s[key]=fn.call(this,a))}.bind(this,fn,s,wm,maxAge>0&&maxAge<I?d:0,serializer);u=1}else{f=function(f,k,v,e,c,m,...a){var i,j,l=m||a.length;for(i=0;i<k.length&&v[i]!==undefined;i++){for(j=0;j<=l&&(k[i][j]===a[j]||e&&e(k[i][j],a[j]));j++){if(j===l)return v[i]}}!c||c(i,v);return v[i]=fn.apply(this,k[i]=a)}.bind(this,fn,k,v,equals,maxAge>0&&maxAge<I?d:0,maxArgs)}f.clear=(_=>{Object.keys(s).forEach(k=>delete s[k]);wm.m=new WeakMap;k.length=0;v.length=0});f.keys=(_=>u?null:k.slice());f.values=(_=>u?null:v.slice());f.keyValues=(_=>u?{primitives:Object.assign({},s),objects:wm.m}:null);return f};if(typeof module!=="undefined")module.exports=nanomemoize;if(typeof window!=="undefined")window.nanomemoize=nanomemoize}).call(this); |
@@ -40,3 +40,3 @@ (function() { | ||
} | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(t) : p(a); | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : p(a); | ||
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a)); | ||
@@ -43,0 +43,0 @@ }).bind( |
{ | ||
"name": "nano-memoize", | ||
"version": "v1.1.3", | ||
"version": "v1.1.4", | ||
"description": "Faster than fast, smaller than micro ... a nano speed and nano size memoizer.", | ||
@@ -5,0 +5,0 @@ "engines": {}, |
@@ -200,2 +200,4 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/30ce201484754fa5b0a6c6046abb842d)](https://www.codacy.com/app/syblackwell/nano-memoize?utm_source=github.com&utm_medium=referral&utm_content=anywhichway/nano-memoize&utm_campaign=Badge_Grade) | ||
2019-05-31 v1.3.4 [Fixed Issue 7](https://github.com/anywhichway/nano-memoize/issues/7). | ||
2019-04-09 v1.1.3 [Fixed Issue 6](https://github.com/anywhichway/nano-memoize/issues/6). Minor speed and size improvements. | ||
@@ -202,0 +204,0 @@ |
@@ -40,3 +40,3 @@ (function() { | ||
} | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(t) : p(a); | ||
var key = t === "number" || t === "boolean" || t==="undefined" ? a : t === "string" ? JSON.stringify(a) : p(a); | ||
return s[key] || ((!c||c(key,s)),s[key] = fn.call(this, a)); | ||
@@ -43,0 +43,0 @@ }).bind( |
@@ -34,3 +34,3 @@ var chai, | ||
}); | ||
it("single primitive arg cached",function() { | ||
it("single primitive number arg cached",function() { | ||
const value = 1, | ||
@@ -42,2 +42,9 @@ result = singleArg(value), | ||
}); | ||
it("single primitive string arg cached",function() { | ||
const value = "1", | ||
result = singleArg(value), | ||
keyvalues = singleArg.keyValues().primitives; | ||
expect(result).to.equal(value); | ||
expect(keyvalues[JSON.stringify(value)]).to.equal(value); | ||
}); | ||
it("single object arg cached",function() { | ||
@@ -44,0 +51,0 @@ const value = {p1:1}, |
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
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
71033
928
0
247