Data
Raw data representation.
Raw data representation of strings, files and images.
Methods
Section titled “Methods”
fromBase64String(base64String)
Section titled “fromBase64String(base64String)”Creates data from base64 encoded string.
static fromBase64String(base64String: string): DataThe supplied string must be base64 encoded otherwise the function will return null.
Parameters
Section titled “Parameters”base64String string
Base64 encoded string to create data from.
Return value
Section titled “Return value”Data
Data representation of the string.
fromBytes(bytes)
Section titled “fromBytes(bytes)”Creates data from an array of bytes.
static fromBytes(bytes: [number]): DataParameters
Section titled “Parameters”bytes [number]
Array of bytes to convert to data.
Return value
Section titled “Return value”Data
Data creates from the bytes.
fromFile(filePath)
Section titled “fromFile(filePath)”Reads data from file path.
static fromFile(filePath: string): DataReads the raw data of the file at the specified file path.
Parameters
Section titled “Parameters”filePath string
Path of file to read data from.
Return value
Section titled “Return value”Data
Data representation of the file.
fromJPEG(image)
Section titled “fromJPEG(image)”Creates data from JPEG image.
static fromJPEG(image: Image): DataParameters
Section titled “Parameters”image Image
JPEG image to convert to data.
Return value
Section titled “Return value”Data
Data representation of the image.
fromPNG(image)
Section titled “fromPNG(image)”Creates data from PNG image.
static fromPNG(image: Image): DataParameters
Section titled “Parameters”image Image
PNG image to convert to data.
Return value
Section titled “Return value”Data
Data representation of the image.
fromString(string)
Section titled “fromString(string)”Creates data from string.
static fromString(string: string): DataThe provided string is assumed to be UTF8 encoded. If the string is not UTF8 encoded, the function will return null.
Parameters
Section titled “Parameters”string string
String to create data from.
Return value
Section titled “Return value”Data
Data representation of the string.
getBytes()
Section titled “getBytes()”Gets bytes from data.
getBytes(): [number]Return value
Section titled “Return value”[number]
Array of bytes.
toBase64String()
Section titled “toBase64String()”Creates a base64 encoded string.
toBase64String(): stringCreates a base64 encoded string from the data.
Return value
Section titled “Return value”string
Base64 encoded string.
toRawString(encoding)
Section titled “toRawString(encoding)”Creates a string from the data.
toRawString(encoding?: string): stringSpecify 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.
Parameters
Section titled “Parameters”encoding string
Optional. IANA character encoding name.
Return value
Section titled “Return value”string
Data converted to string.