Comparing version 0.3.4 to 0.3.5
@@ -94,18 +94,16 @@ 'use strict'; | ||
memoized = function (arg) { | ||
var result, args = arguments; | ||
if (resolve) { | ||
args = resolve(arguments); | ||
arg = args[0]; | ||
var result, args = arguments, id; | ||
if (resolve) args = resolve(arguments); | ||
id = String(args[0]); | ||
if (hasOwnProperty.call(cache, id)) { | ||
if (getListeners) conf.emit('get', id, args, this); | ||
return cache[id]; | ||
} | ||
if (hasOwnProperty.call(cache, arg)) { | ||
if (getListeners) conf.emit('get', arg, args, this); | ||
return cache[arg]; | ||
} | ||
if (args.length === 1) result = call.call(original, this, arg); | ||
if (args.length === 1) result = call.call(original, this, args[0]); | ||
else result = apply.call(original, this, args); | ||
if (hasOwnProperty.call(cache, arg)) { | ||
if (hasOwnProperty.call(cache, id)) { | ||
throw customError("Circular invocation", 'CIRCULAR_INVOCATION'); | ||
} | ||
cache[arg] = result; | ||
if (setListeners) conf.emit('set', arg); | ||
cache[id] = result; | ||
if (setListeners) conf.emit('set', id); | ||
return result; | ||
@@ -120,3 +118,3 @@ }; | ||
if (get) return get(args); | ||
return args[0]; | ||
return String(args[0]); | ||
}, | ||
@@ -123,0 +121,0 @@ has: function (id) { return hasOwnProperty.call(cache, id); }, |
{ | ||
"name": "memoizee", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Memoize/cache", | ||
@@ -5,0 +5,0 @@ "author": "Mariusz Nowak <medikoo@medikoo.com> (http://www.medikoo.com/)", |
@@ -224,2 +224,13 @@ 'use strict'; | ||
}); | ||
}, | ||
"Primitive null arg case": function (a, d) { | ||
var x = {}, mfn = memoize(function f(id, cb) { cb(null, x); }, { | ||
async: true, | ||
primitive: true | ||
}); | ||
mfn(null, function (err, res) { | ||
a.deep([err, res], [null, x], "Args"); | ||
d(); | ||
}); | ||
} | ||
@@ -226,0 +237,0 @@ }, |
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
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
130988
3667