There are two ways to turn a Uint8ArrayList into a Uint8Array - .slice and .subarray and one way to turn a Uint8ArrayList into a Uint8ArrayList with different contents - .sublist.
Subarray attempts to follow the same semantics as Uint8Array.subarray with one important different - this is a no-copy operation, unless the requested bytes span two internal buffers in which case it is a copy operation.
A class that lets you do operations over a list of Uint8Arrays without copying them.
Converting Uint8ArrayLists to Uint8Arrays
There are two ways to turn a
Uint8ArrayList
into aUint8Array
-.slice
and.subarray
and one way to turn aUint8ArrayList
into aUint8ArrayList
with different contents -.sublist
.slice
Slice follows the same semantics as Uint8Array.slice in that it creates a new
Uint8Array
and copies bytes into it using an optional offset & length.subarray
Subarray attempts to follow the same semantics as Uint8Array.subarray with one important different - this is a no-copy operation, unless the requested bytes span two internal buffers in which case it is a copy operation.
sublist
Sublist creates and returns a new
Uint8ArrayList
that shares the underlying buffers with the original so is always a no-copy operation.Inspiration
Borrows liberally from bl but only uses native JS types.