core.normalizearraybufferview | Medplum

normalizeArrayBufferView() function

Normalizes an ArrayBufferLike (eg. an ArrayBuffer) to a raw ArrayBufferLike (without a view). If the passed buffer is a view, it gives the raw ArrayBufferLike.

This is useful in cases where you need to operate on the raw bytes of an ArrayBuffer where a TypedArray (eg. Uint32Array) might be passed in. This ensures that you will always operate on the raw bytes rather than accidentally truncating the input by operating on the elements of the view.

Signature:

export declare function normalizeArrayBufferView(typedArrayOrBuffer: ArrayBufferLike | ArrayBufferView): ArrayBufferLike;

Parameters

Parameter Type Description
typedArrayOrBuffer ArrayBufferLike | ArrayBufferView The ArrayBufferLike (either TypedArray or raw ArrayBuffer) to normalize to raw ArrayBuffer.

Returns:

ArrayBufferLike

The raw ArrayBuffer without a view.