@httpland/range-request-middleware
Version:
HTTP range request middleware
28 lines (27 loc) • 804 B
JavaScript
;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
Object.defineProperty(exports, "__esModule", { value: true });
exports.concat = void 0;
/** Concatenate the given arrays into a new Uint8Array.
*
* ```ts
* import { concat } from "https://deno.land/std@$STD_VERSION/bytes/concat.ts";
* const a = new Uint8Array([0, 1, 2]);
* const b = new Uint8Array([3, 4, 5]);
* console.log(concat(a, b)); // [0, 1, 2, 3, 4, 5]
*/
function concat(...buf) {
let length = 0;
for (const b of buf) {
length += b.length;
}
const output = new Uint8Array(length);
let index = 0;
for (const b of buf) {
output.set(b, index);
index += b.length;
}
return output;
}
exports.concat = concat;