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

es5-ext

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es5-ext - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

135

lib/Function/prototype/memoize.js

@@ -39,6 +39,6 @@ 'use strict';

module.exports = function (length, resolvers) {
var fn, cache, resolver, find, aset, rset, index, found, mfn;
var fn, mfn, resolver, cache, find, save, clear
, value;
fn = callable(this);
cache = [];
if (isArray(length)) {

@@ -52,3 +52,2 @@ resolvers = length;

}
if (resolvers != null) {

@@ -62,55 +61,111 @@ resolvers = toArray(resolvers);

find = function (args) {
var limit, i, arg;
cache = [];
i = 0;
aset = found = false;
index = limit = (length === false) ? args.length : length;
rset = cache;
find = function (length, args) {
var index = 0, rset = cache, i;
if (limit === 0) {
found = rset.hasOwnProperty(0);
if (length === 0) {
value = rset[length];
return rset.hasOwnProperty(length);
} else if ((rset = rset[length])) {
while (index < (length - 1)) {
i = indexOf.call(rset[0], args[index]);
if (i === -1) {
return false;
}
rset = rset[1][i];
++index;
}
i = indexOf.call(rset[0], args[index]);
if (i === -1) {
return false;
}
value = rset[1][i];
return true;
}
return false;
};
save = function (length, args, value) {
var index = 0, rset = cache, i;
if (length === 0) {
rset[length] = value;
} else {
while (i !== limit) {
if (!rset[index]) {
rset = (rset[index] = [[args[i]], []]);
index = 0;
} else if ((index =
indexOf.call((rset = rset[index])[0], args[i])) === -1) {
index = rset[0].push(args[i]) - 1;
found = false;
} else {
found = rset[1].hasOwnProperty(index);
if (!rset[length]) {
rset[length] = [[], []];
}
rset = rset[length];
while (index < (length - 1)) {
i = indexOf.call(rset[0], args[index]);
if (i === -1) {
i = rset[0].push(args[index]) - 1;
rset[1].push([[], []]);
}
aset = rset[0];
rset = rset[1];
++i;
rset = rset[1][i];
++index;
}
i = indexOf.call(rset[0], args[index]);
if (i === -1) {
i = rset[0].push(args[index]) - 1;
}
rset[1][i] = value;
}
};
clear = function (length, args) {
var index = 0, rset = cache, i, path = [];
if (length === 0) {
delete rset[length];
} else if ((rset = rset[length])) {
while (index < (length - 1)) {
i = indexOf.call(rset[0], args[index]);
if (i === -1) {
return;
}
path.push(rset, i);
rset = rset[1][i];
++index;
}
i = indexOf.call(rset[0], args[index]);
if (i === -1) {
return;
}
rset[0].splice(i, 1);
rset[1].splice(i, 1);
while (!rset[0].length && path.length) {
i = path.pop();
rset = path.pop();
rset[0].splice(i, 1);
rset[1].splice(i, 1);
}
}
};
mfn = function () {
var args, result;
var args, alength;
args = resolver ? resolver(arguments) : arguments;
find(args);
if (found) {
result = rset[index];
alength = (length === false) ? args.length : length;
if (find(alength, args)) {
return value;
} else {
mfn.args = arguments;
result = (rset[index] = apply.call(fn, this, args));
mfn.preventCache = false;
value = apply.call(fn, this, args);
if (!mfn.preventCache) {
save(alength, args, value);
}
delete mfn.args;
return value;
}
return result
};
mfn.clearCache = function () {
find(resolver ? resolver(arguments) : arguments);
if (found) {
if (aset) {
aset.splice(index, 1);
rset.splice(index, 1);
} else {
delete rset[index];
}
}
var args, alength;
args = resolver ? resolver(arguments) : arguments;
alength = (length === false) ? args.length : length;
clear(alength, args);
};

@@ -117,0 +172,0 @@

{
"name": "es5-ext",
"version": "0.8.0",
"version": "0.8.1",
"description": "ECMAScript5 extensions",

@@ -5,0 +5,0 @@ "keywords": [

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