javascript-binary-converter
Version:
A utility package to quickly handle and convert various Javascript binary objects
20 lines (19 loc) • 785 B
TypeScript
import { BytesArray, ImageCreationConfig, ToBytesConfig } from "../sharedTypes";
export default class BlobConverter {
protected original: Blob;
constructor(original: Blob);
toUint8Array(): Promise<Uint8Array>;
toInt8Array(): Promise<Int8Array>;
toArrayBuffer(): Promise<ArrayBuffer>;
toImage(config?: ImageCreationConfig): Promise<HTMLImageElement>;
toCanvas(): Promise<HTMLCanvasElement>;
toBytes(): Promise<BytesArray>;
toDecimalBytes({ isSigned }?: ToBytesConfig): Promise<number[]>;
/**
* Returns a base64 string. If you want a dataUrl appended to it, pass {appendDataUrl:true}
* In Node will always return plain base64
*/
toBase64(config?: {
appendDataUrl?: boolean;
}): Promise<string>;
}