12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.concatArgs = exports.seqEqual = void 0;
- /**
- * Check whether two sequences (e.g. Arrays of numbers) are equal.
- *
- * @param arr1 - One of the arrays to compare.
- * @param arr2 - The other array to compare.
- */
- function seqEqual(arr1, arr2) {
- if (arr1.length !== arr2.length) {
- return false;
- }
- for (let i = 0; i < arr1.length; i++) {
- if (arr1[i] !== arr2[i]) {
- return false;
- }
- }
- return true;
- }
- exports.seqEqual = seqEqual;
- /**
- * Check whether a value is a sequence (e.g. Array of numbers).
- *
- * @param val - The value to check.
- */
- function isSequence(val) {
- return val.length !== undefined;
- }
- /**
- * Concatenate all `arguments` into a single array. Each argument can be either
- * a single element or a sequence, which has a `length` property and supports
- * element retrieval via sequence[ix].
- *
- * > concatArgs(1, [2, 3], Buffer.from([4,5]), new Uint8Array([6, 7]));
- * [1,2,3,4,5,6,7]
- *
- * @returns Array of concatenated arguments
- */
- function concatArgs(...args) {
- const ret = [];
- args.forEach((arg) => {
- if (isSequence(arg)) {
- for (const j of arg) {
- ret.push(j);
- }
- }
- else {
- ret.push(arg);
- }
- });
- return ret;
- }
- exports.concatArgs = concatArgs;
- //# sourceMappingURL=utils.js.map
|