Skip to content

Data

Raw data representation.

Raw data representation of strings, files and images.

Creates data from base64 encoded string.

static fromBase64String(base64String: string): Data

The supplied string must be base64 encoded otherwise the function will return null.

base64String string

Base64 encoded string to create data from.

Data

Data representation of the string.

Creates data from an array of bytes.

static fromBytes(bytes: [number]): Data

bytes [number]

Array of bytes to convert to data.

Data

Data creates from the bytes.

Reads data from file path.

static fromFile(filePath: string): Data

Reads the raw data of the file at the specified file path.

filePath string

Path of file to read data from.

Data

Data representation of the file.

Creates data from JPEG image.

static fromJPEG(image: Image): Data

image Image

JPEG image to convert to data.

Data

Data representation of the image.

Creates data from PNG image.

static fromPNG(image: Image): Data

image Image

PNG image to convert to data.

Data

Data representation of the image.

Creates data from string.

static fromString(string: string): Data

The provided string is assumed to be UTF8 encoded. If the string is not UTF8 encoded, the function will return null.

string string

String to create data from.

Data

Data representation of the string.

Gets bytes from data.

getBytes(): [number]

[number]

Array of bytes.

Creates a base64 encoded string.

toBase64String(): string

Creates a base64 encoded string from the data.

string

Base64 encoded string.

Creates a string from the data.

toRawString(encoding?: string): string

Specify an IANA character encoding such as “ISO-8859-1” or “UTF-8”. When omitted, the encoding is detected automatically. Returns null if the encoding is unknown or the data cannot be decoded.

encoding string

Optional. IANA character encoding name.

string

Data converted to string.