mirror of
https://github.com/BreizhHardware/memoizee.git
synced 2026-01-18 16:37:21 +01:00
- Move out main modules from `lib` folder - Introduce `normalizer` based configurations, and convert primitive and regular handlers into thos normalizers (can be found in lib/normalizers folder). Custom normalizers can be provided at run time via `normaizer` option - Provide `plain` module which does not load any extensions or normalizers. Any extensions that have to be used should be required upfront and normalizers should be provided directly - Remove `method` option, instead `methods` and `methods-plan` modules are provided which generate descriptors for lazy created memoized methods - `profile` is no longer extension. To be used it should be required directly - Improve logic for `async` handling - Take out `max` extensionLRU logic into external `lru-queue` package - Remove `context` option - Remove possibility to access original arguments when resolvers are used - Assure expected length of memoized functions
30 lines
927 B
JavaScript
30 lines
927 B
JavaScript
'use strict';
|
|
|
|
module.exports = function (t) {
|
|
return {
|
|
"": function (a) {
|
|
var i = 0, fn = function (x) { ++i; return x; }, mfn
|
|
, y = { toString: function () { return 'foo'; } };
|
|
mfn = t(fn, { primitive: true });
|
|
a(typeof mfn, 'function', "Returns");
|
|
a(mfn.__memoized__, true, "Marked");
|
|
a(t(mfn), mfn, "Do not memoize memoized");
|
|
a(mfn(y), y, "#1");
|
|
a(mfn('foo'), y, "#2");
|
|
a(i, 1, "Called once");
|
|
},
|
|
"Clear cache": function (a) {
|
|
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn
|
|
, y = { toString: function () { return 'foo'; } };
|
|
mfn = t(fn, { primitive: true });
|
|
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#1");
|
|
a(mfn('foo', 'bar', 'zeta'), 'foobarzeta', "#2");
|
|
a(i, 1, "Called once");
|
|
mfn.delete('foo', { toString: function () { return 'bar'; } },
|
|
'zeta');
|
|
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#3");
|
|
a(i, 2, "Called twice");
|
|
}
|
|
};
|
|
};
|