mirror of
https://github.com/BreizhHardware/memoizee.git
synced 2026-01-18 16:37:21 +01:00
Assure unique cache ids among clear calls. Fix #13
This commit is contained in:
@@ -24,7 +24,6 @@ module.exports = function () {
|
||||
clear: function () {
|
||||
argsMap = [];
|
||||
cache = [];
|
||||
lastId = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -66,7 +66,6 @@ module.exports = function (length) {
|
||||
clear: function () {
|
||||
map = [[], []];
|
||||
cache = create(null);
|
||||
lastId = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -83,7 +83,6 @@ module.exports = function () {
|
||||
clear: function () {
|
||||
map = [];
|
||||
cache = create(null);
|
||||
lastId = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -222,6 +222,24 @@ module.exports = function () {
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
"Sync Clear": function (a, d) {
|
||||
var mfn, fn;
|
||||
fn = function (x, cb) {
|
||||
nextTick(function () {
|
||||
cb(null, x);
|
||||
});
|
||||
};
|
||||
|
||||
mfn = memoize(fn, { async: true });
|
||||
mfn(1, function (err, i) {
|
||||
a(i, 1, "First");
|
||||
});
|
||||
mfn.clear();
|
||||
mfn(2, function (err, i) {
|
||||
a(i, 2, "Second");
|
||||
d();
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user