function concat
concat(arrays: Uint8Array[]): Uint8Array

Fast-concatenate Uint8Array arrays into a single array.

Optimized to avoid unnecessary copying:

  • Returns empty array for empty input
  • Returns the original array if only one element (no copy)
  • Otherwise performs efficient concatenation

Examples

Concatenate byte arrays

import { concat } from "jsr:@j50n/proc";

const result = concat([
  new Uint8Array([1, 2]),
  new Uint8Array([3, 4])
]);
// Uint8Array([1, 2, 3, 4])

Single array optimization

import { concat } from "jsr:@j50n/proc";

const arr = new Uint8Array([1, 2, 3]);
const result = concat([arr]);
// Returns arr directly (no copy)

Parameters

arrays: Uint8Array[]

The arrays to concatenate.

Return Type

The concatenated result.