Update to v13 and add queue and completely change code

This commit is contained in:
a 2021-12-06 16:34:00 +01:00
parent dcef23d0ed
commit 55a38726a3
6706 changed files with 424137 additions and 61608 deletions

14
node_modules/ext/test/function/identity.js generated vendored Normal file
View file

@ -0,0 +1,14 @@
"use strict";
var assert = require("chai").assert
, identity = require("../../function/identity");
describe("function/identity", function () {
it("Should return first argument", function () {
assert.equal(identity("foo"), "foo");
var object = {};
assert.equal(identity(object), object);
assert.equal(identity(), undefined);
assert.equal(identity(1, 2, 3), 1);
});
});

13
node_modules/ext/test/global-this/implementation.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
var isObject = require("type/object/is")
, assert = require("chai").assert
, globalThis = require("../../global-this/implementation");
describe("global-this/implementation", function () {
it("Should be an object", function () { assert(isObject(globalThis)); });
it("Should be a global object", function () { assert.equal(globalThis.Array, Array); });
it("Internal resolution should not introduce side-effects", function () {
assert(!("__global__" in Object.prototype));
});
});

10
node_modules/ext/test/global-this/index.js generated vendored Normal file
View file

@ -0,0 +1,10 @@
"use strict";
var isObject = require("type/object/is")
, assert = require("chai").assert
, globalThis = require("../../global-this");
describe("global-this", function () {
it("Should be an object", function () { assert(isObject(globalThis)); });
it("Should be a global object", function () { assert.equal(globalThis.Array, Array); });
});

8
node_modules/ext/test/global-this/is-implemented.js generated vendored Normal file
View file

@ -0,0 +1,8 @@
"use strict";
var assert = require("chai").assert
, isImplemented = require("../../global-this/is-implemented");
describe("global-this/is-implemented", function () {
it("Should return boolean", function () { assert.equal(typeof isImplemented(), "boolean"); });
});

13
node_modules/ext/test/math/ceil-10.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
var assert = require("chai").assert
, ceil10 = require("../../math/ceil-10");
describe("math/ceil-10", function () {
it("Should ceil", function () {
assert.equal(ceil10(55.51, -1), 55.6);
assert.equal(ceil10(51, 1), 60);
assert.equal(ceil10(-55.59, -1), -55.5);
assert.equal(ceil10(-59, 1), -50);
});
});

13
node_modules/ext/test/math/floor-10.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
var assert = require("chai").assert
, floor10 = require("../../math/floor-10");
describe("math/floor-10", function () {
it("Should floor", function () {
assert.equal(floor10(55.59, -1), 55.5);
assert.equal(floor10(59, 1), 50);
assert.equal(floor10(-55.51, -1), -55.6);
assert.equal(floor10(-51, 1), -60);
});
});

19
node_modules/ext/test/math/round-10.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
"use strict";
var assert = require("chai").assert
, round10 = require("../../math/round-10");
describe("math/round-10", function () {
it("Should round", function () {
assert.equal(round10(55.55, -1), 55.6);
assert.equal(round10(55.549, -1), 55.5);
assert.equal(round10(55, 1), 60);
assert.equal(round10(54.9, 1), 50);
assert.equal(round10(-55.55, -1), -55.5);
assert.equal(round10(-55.551, -1), -55.6);
assert.equal(round10(-55, 1), -50);
assert.equal(round10(-55.1, 1), -60);
assert.equal(round10(1.005, -2), 1.01);
assert.equal(round10(-1.005, -2), -1.0);
});
});

26
node_modules/ext/test/object/clear.js generated vendored Normal file
View file

@ -0,0 +1,26 @@
"use strict";
var assert = require("chai").assert
, clear = require("../../object/clear");
describe("object/clear", function () {
it("Should clear enumerable properties", function () {
var obj = { foo: "bar", elo: "sfds" };
clear(obj);
// eslint-disable-next-line no-unreachable-loop
for (var key in obj) throw new Error("Unexpected" + key);
});
it("Should return input object", function () {
var obj = {};
assert.equal(clear(obj), obj);
});
if (Object.defineProperty && Object.keys) {
it("Should keep non enumerable properties", function () {
var obj = { foo: "bar", elo: "sfds" };
Object.defineProperty(obj, "hidden", { value: "some" });
clear(obj);
assert.deepEqual(Object.keys(obj), []);
assert.equal(obj.hidden, "some");
});
}
});

24
node_modules/ext/test/object/entries/_tests.js generated vendored Normal file
View file

@ -0,0 +1,24 @@
"use strict";
var assert = require("chai").assert;
module.exports = function (entries) {
it("Should resolve entries array for an object", function () {
assert.deepEqual(entries({ foo: "bar" }), [["foo", "bar"]]);
});
if (Object.defineProperty) {
it("Should not resolve non-enumerable properties", function () {
var obj = { visible: true };
Object.defineProperty(obj, "hidden", { value: "elo" });
assert.deepEqual(entries(obj), [["visible", true]]);
});
}
it("Should resolve entries array for a primitive", function () {
assert.deepEqual(entries("raz"), [
["0", "r"], ["1", "a"], ["2", "z"]
]);
});
it("Should throw on non-value", function () {
assert["throws"](function () { entries(null); }, TypeError);
});
};

View file

@ -0,0 +1,6 @@
"use strict";
var entries = require("../../../object/entries/implementation")
, tests = require("./_tests");
describe("object/entries/implementation", function () { tests(entries); });

6
node_modules/ext/test/object/entries/index.js generated vendored Normal file
View file

@ -0,0 +1,6 @@
"use strict";
var entries = require("../../../object/entries")
, tests = require("./_tests");
describe("object/entries/index", function () { tests(entries); });

View file

@ -0,0 +1,8 @@
"use strict";
var assert = require("chai").assert
, isImplemented = require("../../../object/entries/is-implemented");
describe("object/entries/is-implemented", function () {
assert.equal(typeof isImplemented(), "boolean");
});

52
node_modules/ext/test/promise/limit.js generated vendored Normal file
View file

@ -0,0 +1,52 @@
"use strict";
var assert = require("chai").assert
, wait = require("timers-ext/promise/sleep")
, limit = require("../../promise/limit").bind(Promise);
describe("promise/limit", function () {
it("Should limit executions", function () {
var count = 0;
var callCount = 0;
var limited = limit(2, function (arg1) {
var id = ++count;
assert.equal(arg1, "foo");
assert.equal(arguments[1], id);
return wait(10).then(function () { return id; });
});
limited("foo", ++callCount);
assert.equal(count, 1);
limited("foo", ++callCount);
assert.equal(count, 2);
limited("foo", ++callCount);
assert.equal(count, 2);
limited("foo", ++callCount);
assert.equal(count, 2);
return wait(25).then(function () {
assert.equal(count, 4);
limited("foo", ++callCount);
assert.equal(count, 5);
limited("foo", ++callCount);
assert.equal(count, 6);
limited("foo", ++callCount);
assert.equal(count, 6);
return wait(25).then(function () { assert.equal(count, 7); });
});
});
it("Should resolve with expected result", function () {
var count = 0;
var limited = limit(2, function () {
var id = ++count;
return wait(10).then(function () { return id; });
});
limited();
assert.equal(count, 1);
limited();
assert.equal(count, 2);
return limited().then(function (result) {
assert.equal(result, 3);
limited().then(function (result) { assert.equal(result, 4); });
});
});
});

36
node_modules/ext/test/string/random.js generated vendored Normal file
View file

@ -0,0 +1,36 @@
"use strict";
var assert = require("chai").assert
, random = require("../../string/random");
var isValidFormat = RegExp.prototype.test.bind(/^[a-z0-9]+$/);
describe("string/random", function () {
it("Should return string", function () { assert.equal(typeof random(), "string"); });
it("Should return by default string of length 10", function () {
assert.equal(random().length, 10);
});
it("Should support custom charset", function () {
var charset = "abc";
var result = random({ charset: charset });
assert.equal(result.length, 10);
for (var i = 0; i < result.length; ++i) {
assert.isAtLeast(charset.indexOf(result.charAt(i)), 0);
}
});
it("Should ensure unique string with `isUnique` option", function () {
assert.notEqual(random({ isUnique: true }), random({ isUnique: true }));
});
it("Should contain only ascii chars", function () { assert(isValidFormat(random())); });
it("Should support `length` option", function () {
assert.equal(random({ length: 4 }).length, 4);
assert.equal(random({ length: 100 }).length, 100);
assert.equal(random({ length: 0 }).length, 0);
});
it("Should crash if unable to generate unique string with `isUnique` optin", function () {
random({ length: 0, isUnique: true });
assert["throws"](function () {
random({ length: 0, isUnique: true });
}, "Cannot generate random string");
});
});

40
node_modules/ext/test/string_/includes/_tests.js generated vendored Normal file
View file

@ -0,0 +1,40 @@
"use strict";
var assert = require("chai").assert;
module.exports = function (includes) {
it("Should return true when context contains search string", function () {
assert.equal(includes.call("razdwatrzy", "dwa"), true);
});
it("Should return true when context starts with search string", function () {
assert.equal(includes.call("razdwa", "raz"), true);
});
it("Should return true when context ends with search string", function () {
assert.equal(includes.call("razdwa", "dwa"), true);
});
it("Should return false when string doesn't contain search string", function () {
assert.equal(includes.call("razdwa", "trzy"), false);
});
it("Should return false when context is empty and search string is not", function () {
assert.equal(includes.call("", "a"), false);
});
it("Should return false when search string is longer than context", function () {
assert.equal(includes.call("raz", "razdwa"), false);
});
it("Should return true when search string is same as context ", function () {
assert.equal(includes.call("raz", "raz"), true);
});
it("Should return true when context starts with search string", function () {
assert.equal(includes.call("razdwa", "raz"), true);
});
it("Should return true when search string is empty", function () {
assert.equal(includes.call("raz", ""), true);
});
it("Should return true when both context and search string are empty", function () {
assert.equal(includes.call("", ""), true);
});
it("Should support position argument", function () {
assert.equal(includes.call("razdwa", "raz", 1), false);
assert.equal(includes.call("razdwa", "dwa", 1), true);
});
};

View file

@ -0,0 +1,5 @@
"use strict";
describe("string_/includes/implementation", function () {
require("./_tests")(require("../../../string_/includes/implementation"));
});

5
node_modules/ext/test/string_/includes/index.js generated vendored Normal file
View file

@ -0,0 +1,5 @@
"use strict";
describe("string_/includes/implementation", function () {
require("./_tests")(require("../../../string_/includes"));
});

View file

@ -0,0 +1,8 @@
"use strict";
var assert = require("chai").assert
, isImplemented = require("../../../string_/includes/is-implemented");
describe("string_/includes/is-implemented", function () {
it("Should return boolean", function () { assert.equal(typeof isImplemented(), "boolean"); });
});

89
node_modules/ext/test/thenable_/finally.js generated vendored Normal file
View file

@ -0,0 +1,89 @@
"use strict";
var assert = require("chai").assert
, sinon = require("sinon")
, identity = require("../../function/identity")
, finallyMethod = require("../../thenable_/finally");
var throwUnexpected = function () { throw new Error("Unexpected"); };
describe("thenable_/finally", function () {
describe("Successful on fulfilled", function () {
var callback, input, result;
before(function () {
callback = sinon.fake();
input = Promise.resolve("foo");
result = finallyMethod.call(input, callback);
return result;
});
it("Should invoke finally callback", function () { assert(callback.calledOnce); });
it("Return promise should fulfill with original result", function () {
return Promise.all([input, result]).then(function (results) {
assert.equal(results[0], results[1]);
});
});
});
describe("Successful on rejected", function () {
var callback, input, result;
before(function () {
var inputError = new Error("Rejected");
callback = sinon.fake();
input = Promise.reject(inputError);
result = finallyMethod.call(input, callback);
return result["catch"](function (error) { if (error !== inputError) throw error; });
});
it("Should invoke finally callback", function () { assert(callback.calledOnce); });
it("Return promise should fulfill with original result", function () {
return Promise.all([input["catch"](identity), result["catch"](identity)]).then(
function (results) { assert.equal(results[0], results[1]); }
);
});
});
describe("Failed on fulfilled", function () {
var callback, result, finallyError;
before(function () {
finallyError = new Error("Finally Rejected");
callback = sinon.fake["throws"](finallyError);
var input = Promise.resolve("foo");
result = finallyMethod.call(input, callback);
return result["catch"](function (error) { if (error !== finallyError) throw error; });
});
it("Should invoke finally callback", function () { assert(callback.calledOnce); });
it("Return promise should be rejected with finally error", function () {
return result.then(throwUnexpected, function (error) {
assert.equal(finallyError, error);
});
});
});
describe("Failed on rejected", function () {
var callback, result, finallyError;
before(function () {
finallyError = new Error("Finally Rejected");
callback = sinon.fake["throws"](finallyError);
var input = Promise.reject(new Error("Rejected"));
result = finallyMethod.call(input, callback);
return result["catch"](function (error) { if (error !== finallyError) throw error; });
});
it("Should invoke finally callback", function () { assert(callback.calledOnce); });
it("Return promise should be rejected with finally error", function () {
return result.then(throwUnexpected, function (error) {
assert.equal(finallyError, error);
});
});
});
});