Class: Blob

Blob

new Blob(value, copy)

A Blob holds an immutable byte array implemented as a Buffer. This should be treated like a string which is a pointer to an immutable string. (It is OK to pass a pointer to the string because the new owner can’t change the bytes of the string.) Blob does not inherit from Buffer. Instead you must call buf() to get the byte array which reminds you that you should not change the contents. Also remember that buf() can return null.
Parameters:
Name Type Description
value Blob | Buffer | Array.<number> (optional) If value is a Blob, take another pointer to the Buffer without copying. If value is a Buffer or byte array, copy to create a new Buffer. If omitted, buf() will return null.
copy boolean (optional) (optional) If true, copy the contents of value into a new Buffer. If false, just use the existing value without copying. If omitted, then copy the contents (unless value is already a Blob). IMPORTANT: If copy is false, if you keep a pointer to the value then you must treat the value as immutable and promise not to change it.
Source:

Methods

buf() → {Buffer}

Return the immutable byte array. DO NOT change the contents of the Buffer. If you need to change it, make a copy.
Source:
Returns:
The Buffer holding the immutable byte array, or null.
Type
Buffer

equals(other) → {boolean}

Check if the value of this Blob equals the other blob.
Parameters:
Name Type Description
other Blob The other Blob to check.
Source:
Returns:
if this isNull and other isNull or if the bytes of this blob equal the bytes of the other.
Type
boolean

isNull() → {boolean}

Return true if the array is null, otherwise false.
Source:
Returns:
True if the array is null.
Type
boolean

size() → {number}

Return the length of the immutable byte array.
Source:
Returns:
The length of the array. If buf() is null, return 0.
Type
number

toHex() → {string}

Return the hex representation of the bytes in the byte array.
Source:
Returns:
The hex string.
Type
string

toString()

Decode the byte array as UTF8 and return the Unicode string.
Source:
Returns:
A unicode string, or "" if the buffer is null.