Data conversion
Helper functions for converting data
ArcOS has several utilities built-in for converting data to different formats. All of these helper functions are part of the convert
object. Here's what you get:
export function arrayToText(buffer: ArrayLike<number> | ArrayBufferLike): string;
Converts an ArrayBuffer
to a string
.
export function textToArrayBuffer(text: string): ArrayBuffer;
Converts a string
to an ArrayBuffer
.
export function blobToText(blob: Blob): Promise<string>;
Asynchronously converts a Blob
to a string
.
export function textToBlob(text: string, type?: string): Blob;
Converts a string
to a Blob
, optionally specifying a mimetype.
export function arrayToBlob(buffer: ArrayBuffer, type?: string): Blob;
Converts an ArrayBuffer
to a string
, optionally specifying a mimetype.
export function blobToDataURL(blob: Blob): Promise<string | undefined>;
Converts a Blob
to a Data URL
Ofcourse you have all the flexibility you need to convert data your own way, these are just the functions that I've written for ArcOS to make data conversion with especially filesystem operations easier.
Last updated