mirror of
https://github.com/biobulkbende/biobulkbende.org.git
synced 2025-10-11 23:25:00 +00:00
structure, layout and automation
This commit is contained in:
62
node_modules/memoizee/test/normalizers/get-1.js
generated
vendored
Normal file
62
node_modules/memoizee/test/normalizers/get-1.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/* eslint id-length: 0, no-shadow: 0, no-unused-vars: 0 */
|
||||
|
||||
"use strict";
|
||||
|
||||
var memoize = require("../..");
|
||||
|
||||
module.exports = {
|
||||
"": function (t, a) {
|
||||
var i = 0
|
||||
, fn = function (x) {
|
||||
++i;
|
||||
return x;
|
||||
};
|
||||
|
||||
fn = memoize(fn);
|
||||
return {
|
||||
"No arg": function () {
|
||||
i = 0;
|
||||
a(fn(), undefined, "First");
|
||||
a(fn(), undefined, "Second");
|
||||
a(fn(), undefined, "Third");
|
||||
a(i, 1, "Called once");
|
||||
},
|
||||
"Arg": function () {
|
||||
var x = {};
|
||||
i = 0;
|
||||
a(fn(x, 8), x, "First");
|
||||
a(fn(x, 4), x, "Second");
|
||||
a(fn(x, 2), x, "Third");
|
||||
a(i, 1, "Called once");
|
||||
},
|
||||
"Other Arg": function () {
|
||||
var x = {};
|
||||
i = 0;
|
||||
a(fn(x, 2), x, "First");
|
||||
a(fn(x, 9), x, "Second");
|
||||
a(fn(x, 3), x, "Third");
|
||||
a(i, 1, "Called once");
|
||||
}
|
||||
};
|
||||
},
|
||||
"Delete": function (a) {
|
||||
var i = 0, fn, mfn, x = {};
|
||||
|
||||
fn = function (a, b, c) {
|
||||
return a + ++i;
|
||||
};
|
||||
mfn = memoize(fn, { length: 1 });
|
||||
a(mfn(3), 4, "Init");
|
||||
a(mfn(4, x, 1), 6, "Init #2");
|
||||
mfn.delete(4);
|
||||
a(mfn(3, x, 1), 4, "Cached");
|
||||
mfn(3, x, 1);
|
||||
a(i, 2, "Pre clear");
|
||||
mfn.delete(3, x, 1);
|
||||
a(i, 2, "After clear");
|
||||
a(mfn(3, x, 1), 6, "Reinit");
|
||||
a(i, 3, "Reinit count");
|
||||
a(mfn(3, x, 1), 6, "Reinit Cached");
|
||||
a(i, 3, "Reinit count");
|
||||
}
|
||||
};
|
98
node_modules/memoizee/test/normalizers/get-fixed.js
generated
vendored
Normal file
98
node_modules/memoizee/test/normalizers/get-fixed.js
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/* eslint id-length: 0, no-shadow: 0, no-unused-vars: 0 */
|
||||
|
||||
"use strict";
|
||||
|
||||
var memoize = require("../..");
|
||||
|
||||
module.exports = {
|
||||
"": function (a) {
|
||||
var i = 0
|
||||
, fn = function (x, y, z) {
|
||||
++i;
|
||||
return [x, y, z];
|
||||
}
|
||||
, r;
|
||||
|
||||
fn = memoize(fn);
|
||||
return {
|
||||
"No args": function () {
|
||||
i = 0;
|
||||
a.deep(r = fn(), [undefined, undefined, undefined], "First");
|
||||
a(fn(), r, "Second");
|
||||
a(fn(), r, "Third");
|
||||
a(i, 1, "Called once");
|
||||
},
|
||||
"Some Args": function () {
|
||||
var x = {};
|
||||
i = 0;
|
||||
a.deep(r = fn(x, 8), [x, 8, undefined], "First");
|
||||
a(fn(x, 8), r, "Second");
|
||||
a(fn(x, 8), r, "Third");
|
||||
a(i, 1, "Called once");
|
||||
return {
|
||||
Other: function () {
|
||||
a.deep(r = fn(x, 5), [x, 5, undefined], "Second");
|
||||
a(fn(x, 5), r, "Third");
|
||||
a(i, 2, "Called once");
|
||||
}
|
||||
};
|
||||
},
|
||||
"Full stuff": function () {
|
||||
var x = {};
|
||||
i = 0;
|
||||
a.deep(r = fn(x, 8, 23, 98), [x, 8, 23], "First");
|
||||
a(fn(x, 8, 23, 43), r, "Second");
|
||||
a(fn(x, 8, 23, 9), r, "Third");
|
||||
a(i, 1, "Called once");
|
||||
return {
|
||||
Other: function () {
|
||||
a.deep(r = fn(x, 23, 8, 13), [x, 23, 8], "Second");
|
||||
a(fn(x, 23, 8, 22), r, "Third");
|
||||
a(i, 2, "Called once");
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
},
|
||||
"Delete": function (a) {
|
||||
var i = 0, fn, mfn, x = {};
|
||||
|
||||
fn = function (a, b, c) {
|
||||
return a + ++i;
|
||||
};
|
||||
mfn = memoize(fn);
|
||||
a(mfn(3, x, 1), 4, "Init");
|
||||
a(mfn(4, x, 1), 6, "Init #2");
|
||||
mfn.delete(4, x, 1);
|
||||
a(mfn(3, x, 1), 4, "Cached");
|
||||
mfn(3, x, 1);
|
||||
a(i, 2, "Pre clear");
|
||||
mfn.delete(3, x, 1);
|
||||
a(i, 2, "After clear");
|
||||
a(mfn(3, x, 1), 6, "Reinit");
|
||||
a(i, 3, "Reinit count");
|
||||
a(mfn(3, x, 1), 6, "Reinit Cached");
|
||||
a(i, 3, "Reinit count");
|
||||
},
|
||||
"Clear": function (a) {
|
||||
var i = 0, fn, x = {};
|
||||
|
||||
fn = function () {
|
||||
++i;
|
||||
return arguments;
|
||||
};
|
||||
|
||||
fn = memoize(fn, { length: 3 });
|
||||
fn(1, x, 3);
|
||||
fn(1, x, 4);
|
||||
fn(1, x, 3);
|
||||
fn(1, x, 4);
|
||||
a(i, 2, "Pre clear");
|
||||
fn.clear();
|
||||
fn(1, x, 3);
|
||||
fn(1, x, 4);
|
||||
fn(1, x, 3);
|
||||
fn(1, x, 4);
|
||||
a(i, 4, "After clear");
|
||||
}
|
||||
};
|
70
node_modules/memoizee/test/normalizers/get-primitive-fixed.js
generated
vendored
Normal file
70
node_modules/memoizee/test/normalizers/get-primitive-fixed.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/* eslint id-length: 0 */
|
||||
|
||||
"use strict";
|
||||
|
||||
var memoize = require("../..");
|
||||
|
||||
module.exports = {
|
||||
"": function (a) {
|
||||
var i = 0
|
||||
, fn = function (x, y, z) {
|
||||
++i;
|
||||
return x + y + z;
|
||||
}
|
||||
, mfn
|
||||
, y = {
|
||||
toString: function () {
|
||||
return "foo";
|
||||
}
|
||||
};
|
||||
mfn = memoize(fn, { primitive: true });
|
||||
a(mfn(y, "bar", "zeta"), "foobarzeta", "#1");
|
||||
a(mfn("foo", "bar", "zeta"), "foobarzeta", "#2");
|
||||
a(i, 1, "Called once");
|
||||
},
|
||||
"Delete": function (a) {
|
||||
var i = 0
|
||||
, fn = function (x, y, z) {
|
||||
++i;
|
||||
return x + y + z;
|
||||
}
|
||||
, mfn
|
||||
, y = {
|
||||
toString: function () {
|
||||
return "foo";
|
||||
}
|
||||
};
|
||||
mfn = memoize(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");
|
||||
},
|
||||
"Clear": function (a) {
|
||||
var i = 0, fn;
|
||||
fn = memoize(function (x) {
|
||||
if (++i < 2) fn(x);
|
||||
});
|
||||
a.throws(function () {
|
||||
fn("foo");
|
||||
}, "CIRCULAR_INVOCATION");
|
||||
|
||||
i = 0;
|
||||
fn = memoize(function (x, y) {
|
||||
if (++i < 2) fn(x, y);
|
||||
});
|
||||
a.throws(function () {
|
||||
fn("foo", "bar");
|
||||
}, "CIRCULAR_INVOCATION");
|
||||
}
|
||||
};
|
66
node_modules/memoizee/test/normalizers/get.js
generated
vendored
Normal file
66
node_modules/memoizee/test/normalizers/get.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/* eslint id-length: 0, no-shadow: 0, no-unused-vars: 0 */
|
||||
|
||||
"use strict";
|
||||
|
||||
var aFrom = require("es5-ext/array/from")
|
||||
, memoize = require("../..");
|
||||
|
||||
module.exports = function () {
|
||||
return {
|
||||
"": function (a) {
|
||||
var i = 0
|
||||
, fn = function () {
|
||||
++i;
|
||||
return arguments;
|
||||
}
|
||||
, r;
|
||||
|
||||
fn = memoize(fn, { length: false });
|
||||
return {
|
||||
"No args": function () {
|
||||
i = 0;
|
||||
a.deep(aFrom(r = fn()), [], "First");
|
||||
a(fn(), r, "Second");
|
||||
a(fn(), r, "Third");
|
||||
a(i, 1, "Called once");
|
||||
},
|
||||
"Some Args": function () {
|
||||
var x = {};
|
||||
i = 0;
|
||||
a.deep(aFrom(r = fn(x, 8)), [x, 8], "First");
|
||||
a(fn(x, 8), r, "Second");
|
||||
a(fn(x, 8), r, "Third");
|
||||
a(i, 1, "Called once");
|
||||
},
|
||||
"Many args": function () {
|
||||
var x = {};
|
||||
i = 0;
|
||||
a.deep(aFrom(r = fn(x, 8, 23, 98)), [x, 8, 23, 98], "First");
|
||||
a(fn(x, 8, 23, 98), r, "Second");
|
||||
a(fn(x, 8, 23, 98), r, "Third");
|
||||
a(i, 1, "Called once");
|
||||
}
|
||||
};
|
||||
},
|
||||
"Delete": function (a) {
|
||||
var i = 0, fn, mfn, x = {};
|
||||
|
||||
fn = function (a, b, c) {
|
||||
return a + ++i;
|
||||
};
|
||||
mfn = memoize(fn, { length: false });
|
||||
a(mfn(3, x, 1), 4, "Init");
|
||||
a(mfn(4, x, 1), 6, "Init #2");
|
||||
mfn.delete(4, x, 1);
|
||||
a(mfn(3, x, 1), 4, "Cached");
|
||||
mfn(3, x, 1);
|
||||
a(i, 2, "Pre clear");
|
||||
mfn.delete(3, x, 1);
|
||||
a(i, 2, "After clear");
|
||||
a(mfn(3, x, 1), 6, "Reinit");
|
||||
a(i, 3, "Reinit count");
|
||||
a(mfn(3, x, 1), 6, "Reinit Cached");
|
||||
a(i, 3, "Reinit count");
|
||||
}
|
||||
};
|
||||
};
|
28
node_modules/memoizee/test/normalizers/primitive.js
generated
vendored
Normal file
28
node_modules/memoizee/test/normalizers/primitive.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/* eslint id-length: 0 */
|
||||
|
||||
"use strict";
|
||||
|
||||
var memoize = require("../..")
|
||||
, join = Array.prototype.join;
|
||||
|
||||
module.exports = function (a) {
|
||||
var i = 0
|
||||
, fn = function () {
|
||||
++i;
|
||||
return join.call(arguments, "|");
|
||||
}
|
||||
, y = {
|
||||
toString: function () {
|
||||
return "foo";
|
||||
}
|
||||
}
|
||||
, mfn;
|
||||
mfn = memoize(fn, { primitive: true, length: false });
|
||||
a(mfn(y, "bar", "zeta"), "foo|bar|zeta", "#1");
|
||||
a(mfn("foo", "bar", "zeta"), "foo|bar|zeta", "#2");
|
||||
a(i, 1, "Called once");
|
||||
a(mfn(y, "bar"), "foo|bar", "#3");
|
||||
a(i, 2, "Called twice");
|
||||
a(mfn(y, "bar"), "foo|bar", "#4");
|
||||
a(i, 2, "Called twice #2");
|
||||
};
|
Reference in New Issue
Block a user