Assure unique cache ids among clear calls. Fix #13

This commit is contained in:
Mariusz Nowak
2014-06-22 12:05:03 +02:00
parent 307736caec
commit 4168a0e9cd
4 changed files with 18 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ module.exports = function () {
clear: function () {
argsMap = [];
cache = [];
lastId = 0;
}
};
};

View File

@@ -66,7 +66,6 @@ module.exports = function (length) {
clear: function () {
map = [[], []];
cache = create(null);
lastId = 0;
}
};
};

View File

@@ -83,7 +83,6 @@ module.exports = function () {
clear: function () {
map = [];
cache = create(null);
lastId = 0;
}
};
};

View File

@@ -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();
});
}
};
};