The constructor for the buffer, either ArrayBuffer or SharedArrayBuffer.
An object specifying the desired views. Each key represents the name of the view, and the value is a tuple where:
An object containing the views, with each key corresponding to the provided configuration.
import { createArrayBufferViews } from '@ain1084/array-buffer-partitioner';
const views = createArrayBufferViews(ArrayBuffer, {
data: [Float32Array, 1024],
index: [Uint32Array, 1],
flag: [Uint8Array, 1]
});
console.log(views.data.length); // 1024
console.log(views.data.byteOffset); // 0
console.log(views.index.length); // 1
console.log(views.flag.length); // 1
console.log(views.flag.byteOffset); // 4100
console.log(views.data.buffer.byteLength); // 4104
Creates multiple TypedArray views on a single ArrayBuffer or SharedArrayBuffer. The function takes a constructor (either ArrayBuffer or SharedArrayBuffer) and a configuration object, then allocates the buffer and returns the specified TypedArray views.