1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.concatArgs = exports.seqEqual = void 0;
|
4 | /**
|
5 | * Check whether two sequences (e.g. arrays of numbers) are equal.
|
6 | *
|
7 | * @param arr1 One of the arrays to compare.
|
8 | * @param arr2 The other array to compare.
|
9 | */
|
10 | function seqEqual(arr1, arr2) {
|
11 | if (arr1.length !== arr2.length) {
|
12 | return false;
|
13 | }
|
14 | for (let i = 0; i < arr1.length; i++) {
|
15 | if (arr1[i] !== arr2[i]) {
|
16 | return false;
|
17 | }
|
18 | }
|
19 | return true;
|
20 | }
|
21 | exports.seqEqual = seqEqual;
|
22 | /**
|
23 | * Check whether a value is a sequence (e.g. array of numbers).
|
24 | *
|
25 | * @param val The value to check.
|
26 | */
|
27 | function isSequence(val) {
|
28 | return val.length !== undefined;
|
29 | }
|
30 | /**
|
31 | * Concatenate all `arguments` into a single array. Each argument can be either
|
32 | * a single element or a sequence, which has a `length` property and supports
|
33 | * element retrieval via sequence[ix].
|
34 | *
|
35 | * > concatArgs(1, [2, 3], Buffer.from([4,5]), new Uint8Array([6, 7]));
|
36 | * [1,2,3,4,5,6,7]
|
37 | *
|
38 | * @returns {number[]} Array of concatenated arguments
|
39 | */
|
40 | function concatArgs(...args) {
|
41 | const ret = [];
|
42 | args.forEach(function (arg) {
|
43 | if (isSequence(arg)) {
|
44 | for (let j = 0; j < arg.length; j++) {
|
45 | ret.push(arg[j]);
|
46 | }
|
47 | }
|
48 | else {
|
49 | ret.push(arg);
|
50 | }
|
51 | });
|
52 | return ret;
|
53 | }
|
54 | exports.concatArgs = concatArgs;
|
55 | //# sourceMappingURL=utils.js.map |
\ | No newline at end of file |