1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /* eslint id-length: 0, no-shadow: 0, no-unused-vars: 0 */
- "use strict";
- module.exports = function (t, a, d) {
- var value = [], obj = {}, memoized, count = 0, x, y, z;
- memoized = t(
- function (arg, x, y) {
- a(arg, obj);
- return x + y;
- },
- {
- refCounter: true,
- dispose: function (val) {
- value.push(val);
- }
- }
- );
- a(memoized(obj, 3, 7), 10);
- a(memoized(obj, 5, 8), 13);
- a(memoized(obj, 12, 4), 16);
- a.deep(value, [], "Pre");
- a(memoized(obj, 5, 8), 13);
- memoized.deleteRef(obj, 5, 8);
- a.deep(value, [], "Pre");
- memoized.deleteRef(obj, 5, 8);
- a.deep(value, [13], "#1");
- value = [];
- memoized.deleteRef(obj, 12, 4);
- a.deep(value, [16], "#2");
- value = [];
- memoized(obj, 77, 11);
- x = {};
- y = {};
- z = {};
- memoized = t(function (arg) {
- return ++count;
- });
- a(memoized(x), 1);
- a(memoized(y), 2);
- a(memoized(x), 1);
- a(memoized(z), 3);
- a(count, 3);
- count = 0;
- memoized = t(
- function (arg) {
- return ++count;
- },
- { maxAge: 1 }
- );
- memoized(obj);
- setTimeout(function () {
- memoized(obj);
- a(count, 2);
- d();
- }, 100);
- };
|