mirror of
https://github.com/BreizhHardware/memoizee.git
synced 2026-01-18 16:37:21 +01:00
Add duplicate memoization prevention
This commit is contained in:
@@ -14,6 +14,7 @@ var customError = require('es5-ext/error/custom')
|
||||
, resolveNormalize = require('./resolve-normalize')
|
||||
|
||||
, slice = Array.prototype.slice, defineProperties = Object.defineProperties
|
||||
, hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
, clearOnDispose;
|
||||
|
||||
clearOnDispose = function () {
|
||||
@@ -26,6 +27,10 @@ module.exports = function (memoize) {
|
||||
var map, length, options = normalizeOpts(arguments[1]), memoized, resolve, normalizer;
|
||||
|
||||
callable(fn);
|
||||
|
||||
// Do not memoize already memoized function
|
||||
if (hasOwnProperty.call(fn, '__memoized__') && !options.force) return fn;
|
||||
|
||||
length = resolveLength(options.length, fn.length, options.async && extensions.async);
|
||||
options.length = length ? length - 1 : 0;
|
||||
map = new WeakMap();
|
||||
|
||||
Reference in New Issue
Block a user