import { Buffer } from 'buffer'; export interface TypedArrayClassType { new (...args: any[]): T; readonly BYTES_PER_ELEMENT: number; } export interface TypedArray { /** * The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; /** * The ArrayBuffer instance referenced by the array. */ readonly buffer: ArrayBufferLike; /** * The length of the array. */ readonly length: number; /** * The length in bytes of the array. */ readonly byteLength: number; /** * The offset in bytes of the array. */ readonly byteOffset: number; } export declare function nodeBufferToTypedArray(buf: Buffer, type: TypedArrayClassType): K; /** * When using Buffer.from() node is using a buffer from the buffer pool. * This makes it necessary to create the given TypedArray using byteOffset and byteLength accordingly. * * Note: The created TypedArray.buffer is pointing probably to a larger Buffer. Make sure * to use byteLength/byeOffset correctly or use typedArrayToArrayBuffer() if you want to use * a raw ArrayBuffer that represents the actual data correctly. */ export declare function base64ToTypedArray(base64: string, type: TypedArrayClassType): K; /** * Creates a new fresh ArrayBuffer with given data. * Note: Regular Buffer.from(base64, 'base64) creates in Node a shared buffer, this function makes * sure a copy happens and the ArrayBuffer is not shared. */ export declare function base64ToArrayBuffer(base64: string): ArrayBuffer; /** * When using Buffer.from() node is using a buffer from the buffer pool. * This makes it necessary to create the a new ArrayType using slice to make a copy. * * This makes a copy. */ export declare function nodeBufferToArrayBuffer(buf: Buffer): ArrayBuffer; /** * In node environment the TypedArray.buffer is probably a larger buffer from the buffer pool. * This makes it necessary to create a Buffer with offset & length so that it accurately represents * the given TypedArray. */ export declare function typedArrayToBuffer(typedArray: TypedArray): Buffer; export declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string; export declare function typedArrayToBase64(typedArray: TypedArray): string; /** * Same as Buffer.from() but creates a ArrayBuffer that is not shared. */ export declare function arrayBufferFrom(data: string, encoding?: string): ArrayBuffer; /** * Same as Buffer.from(arrayBuffer).toString(encoding), but more in line with the current API. */ export declare function arrayBufferTo(arrayBuffer: ArrayBuffer, encoding?: string | 'utf8' | 'base64' | 'ascii'): string;