Debian Codegraph @

memoizee/test/normalizers/get-primitive-fixed.js

raw
1 /* eslint id-length: 0 */
2
3 "use strict";
4
5 var memoize = require("../..");
6
7 module.exports = {
8 "": function (a) {
9 var i = 0
10 , fn = function (x, y, z) {
11 ++i;
12 return x + y + z;
13 }
14 , mfn
15 , y = { toString: function () { return "foo"; } };
16 mfn = memoize(fn, { primitive: true });
17 a(mfn(y, "bar", "zeta"), "foobarzeta", "#1");
18 a(mfn("foo", "bar", "zeta"), "foobarzeta", "#2");
19 a(i, 1, "Called once");
20 },
21 "Delete": function (a) {
22 var i = 0
23 , fn = function (x, y, z) {
24 ++i;
25 return x + y + z;
26 }
27 , mfn
28 , y = { toString: function () { return "foo"; } };
29 mfn = memoize(fn, { primitive: true });
30 a(mfn(y, "bar", "zeta"), "foobarzeta", "#1");
31 a(mfn("foo", "bar", "zeta"), "foobarzeta", "#2");
32 a(i, 1, "Called once");
33 mfn.delete("foo", { toString: function () { return "bar"; } }, "zeta");
34 a(mfn(y, "bar", "zeta"), "foobarzeta", "#3");
35 a(i, 2, "Called twice");
36 },
37 "Clear": function (a) {
38 var i = 0, fn;
39 fn = memoize(function (x) { if (++i < 2) fn(x); });
40 a.throws(function () { fn("foo"); }, "CIRCULAR_INVOCATION");
41
42 i = 0;
43 fn = memoize(function (x, y) { if (++i < 2) fn(x, y); });
44 a.throws(function () { fn("foo", "bar"); }, "CIRCULAR_INVOCATION");
45 },
46 };