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

memoizee

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memoizee - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

44

lib/ext/async.js

@@ -12,3 +12,3 @@ 'use strict';

require('../_base').ext.async = function (ignore, conf, options) {
require('../_base').ext.async = function (ignore, conf) {
var cache, purge;

@@ -19,3 +19,3 @@

(function (org) {
var value, cb, initContext, initArgs;
var value, cb, initContext, initArgs, fn, resolver;

@@ -48,3 +48,3 @@ conf.on('init', function (id) {

conf.fn = function () {
var id, args, asyncArgs;
var args, asyncArgs;
args = arguments;

@@ -72,3 +72,3 @@ asyncArgs = toArray(args);

}
for (i = 0; cb = waiting[i]; ++i) {
for (i = 0; (cb = waiting[i]); ++i) {
res = apply.call(cb, this, arguments);

@@ -81,23 +81,21 @@ }

(function (fn) {
var resolver = function (args) {
cb = last.call(args);
if (isCallable(cb)) {
return slice.call(args, 0, -1);
} else {
cb = null;
return args;
}
fn = conf.memoized;
resolver = function (args) {
cb = last.call(args);
if (isCallable(cb)) {
return slice.call(args, 0, -1);
} else {
cb = null;
return args;
}
};
conf.memoized = function () {
return fn.apply(initContext = this, initArgs = resolver(arguments));
};
forEach(fn, function (value, name) {
conf.memoized[name] = function () {
return fn[name].apply(this, resolver(arguments));
};
conf.memoized = function () {
return fn.apply(initContext = this, initArgs = resolver(arguments));
};
forEach(fn, function (value, name) {
memoized[name] = function () {
return fn[name].apply(this, resolver(arguments));
};
});
});
}(conf.memoized));
}(conf.fn));

@@ -104,0 +102,0 @@

@@ -7,3 +7,3 @@ 'use strict';

, isArray = Array.isArray, slice = Array.prototype.slice;
, slice = Array.prototype.slice;

@@ -28,7 +28,5 @@ ext.dispose = function (dispose, conf, options) {

conf.on('purgeall', function () {
forEach(conf.cache, function (value, id, cache) {
clear(id);
});
forEach(conf.cache, function (value, id) { clear(id); });
});
}
};
'use strict';
var forEach = require('es5-ext/lib/Object/for-each')
, ext = require('../_base').ext
, ext = require('../_base').ext;

@@ -25,3 +25,3 @@ ext.maxAge = function (maxAge, conf, options) {

if (!async) {
conf.on('purgeall', function (id) {
conf.on('purgeall', function () {
forEach(cache, function (id) {

@@ -28,0 +28,0 @@ clearTimeout(id);

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

ext.max = function (max, conf, options) {
var index, base, size, add, top, clear, queue, map, async;
var index, base, size, queue, map, async;

@@ -31,7 +31,7 @@ max = max >>> 0;

var oldIndex = map[id];
queue[++index] = queue[oldIndex];
queue[++index] = id;
map[id] = index;
delete queue[oldIndex];
if (base === oldIndex) {
while (!queue.hasOwnProperty(++base)) continue;
while (!queue.hasOwnProperty(++base)) continue; //jslint: skip
}

@@ -49,3 +49,3 @@ });

} else {
while (!queue.hasOwnProperty(++base)) continue;
while (!queue.hasOwnProperty(++base)) continue; //jslint: skip
}

@@ -56,3 +56,3 @@ }

if (!async) {
conf.on('purgeall', function (id) {
conf.on('purgeall', function () {
index = -1;

@@ -59,0 +59,0 @@ base = size = 0;

'use strict';
var extend = require('es5-ext/lib/Object/extend')
var global = require('es5-ext/lib/global')
, extend = require('es5-ext/lib/Object/extend')
, isString = require('es5-ext/lib/String/is-string')
, slice = Array.prototype.slice, create = Object.create
, defineProperty = Object.defineProperty;
, create = Object.create, defineProperty = Object.defineProperty;

@@ -17,3 +17,3 @@ require('../_base').ext.method = function (method, conf, options) {

method.descriptor = (method.descriptor == null) ?
{ configurable: true, writable: true } : Object(method.descriptor);
{ configurable: true, writable: true } : Object(method.descriptor);
}

@@ -20,0 +20,0 @@ options = create(options);

@@ -5,3 +5,2 @@ 'use strict';

, forEach = require('es5-ext/lib/Object/for-each')
, contains = require('es5-ext/lib/String/prototype/contains')
, pad = require('es5-ext/lib/String/prototype/pad')

@@ -15,3 +14,3 @@

var id, stack, data;
stack = (new Error()).stack
stack = (new Error()).stack;
if (!stack.split('\n').slice(3).some(function (line) {

@@ -34,4 +33,4 @@ if ((line.indexOf('/memoizee/') === -1) &&

conf.on('init', function (id) { ++data.initial; });
conf.on('hit', function (id) { ++data.cached; });
conf.on('init', function () { ++data.initial; });
conf.on('hit', function () { ++data.cached; });
};

@@ -41,3 +40,3 @@ ext.force = true;

exports.log = function () {
var initial, cached, time, ordered, ipad, cpad, ppad, toPrc, tpad, atime, log;
var initial, cached, time, ordered, ipad, cpad, ppad, toPrc, log;

@@ -44,0 +43,0 @@ initial = cached = time = 0;

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

ext.refCounter = function (ignore, conf, options) {
var cache, get, clear, async;
var cache, async;

@@ -27,3 +27,3 @@ cache = {};

if (!--cache[id]) {
conf.clear(id)
conf.clear(id);
return true;

@@ -30,0 +30,0 @@ }

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

, apply = Function.prototype.apply;
, call = Function.prototype.call;

@@ -20,3 +20,3 @@ // Order is important!

var options = Object(arguments[1]);
return apply.call(options.primitive ? primitive : regular, this, arguments);
return call.call(options.primitive ? primitive : regular, this, fn, options);
};

@@ -30,3 +30,3 @@ 'use strict';

} else if (length) {
get = conf.get = function(args) {
get = conf.get = function (args) {
var id = String(args[0]), i = 0, l = length;

@@ -33,0 +33,0 @@ while (--l) { id += '\u0001' + args[++i]; }

@@ -37,3 +37,4 @@ 'use strict';

if (length === 1) {
map1 = []; map2 = [];
map1 = [];
map2 = [];
get = conf.get = function (args) {

@@ -111,3 +112,3 @@ return map2[indexOf.call(map1, args[0])];

clear = function (args) {
var index = 0, set = map, i, length = args.length, path =[], id;
var index = 0, set = map, i, length = args.length, path = [], id;
if (length === 0) {

@@ -184,3 +185,3 @@ id = set[length];

clear = function (args) {
var index = 0, set = map, i, path =[], id;
var index = 0, set = map, i, path = [], id;
while (index < (length - 1)) {

@@ -187,0 +188,0 @@ i = indexOf.call(set[0], args[index]);

{
"name": "memoizee",
"version": "0.2.0",
"version": "0.2.1",
"description": "Complete memoize/cache solution. Works with any type and length of function arguments",

@@ -5,0 +5,0 @@ "main": "lib",

'use strict';
module.exports = function (t, a) {
var mfn, m = t(function (conf, length) {
var mfn, m = t(function (conf) {
conf.get = function () { return 'test'; };

@@ -12,5 +12,5 @@ conf.memoized = function (x, y, z) { return conf.fn(z, y, x); };

a(typeof m, 'function', "Returns");
mfn = m(function (x, y, z) { return [x, y, z] });
mfn = m(function (x, y, z) { return [x, y, z]; });
a(typeof mfn, 'function', "Generates");
a.deep(mfn(3, 7, 11), [11, 7, 3], "Works");
};

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

module.exports = function (a) {
module.exports = function () {
return {

@@ -228,2 +228,2 @@ "Regular": {

};
};
};

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

module.exports = function (a) {
module.exports = function () {
return {

@@ -9,0 +9,0 @@ "Regular": {

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

module.exports = function (a) {
module.exports = function () {
return {

@@ -9,0 +9,0 @@ "Regular": {

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

module.exports = function (a) {
module.exports = function () {
return {

@@ -9,0 +9,0 @@ "Regular": {

@@ -5,3 +5,3 @@ 'use strict';

module.exports = function (a) {
module.exports = function () {
return {

@@ -8,0 +8,0 @@ "No descriptor": function (a) {

'use strict';
var memoize = require('../../lib');
module.exports = function (t, a) {

@@ -6,0 +4,0 @@ a(typeof t.statistics, 'object', "Access to statistics");

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

module.exports = function (a) {
return {
module.exports = function () {
return {
"Regular": function (a) {

@@ -10,0 +10,0 @@ var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn;

'use strict';
module.exports = function (t, a) {
module.exports = function (t) {
return {

@@ -5,0 +5,0 @@ "No args": function (a) {

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