Class: SDB

SDB()

Handles encoding and decoding of Services Descriptor Bundle data to / from various formats.

Constructor

new SDB()

Creates a new SDB instance.
Source:
See:

Members

(static) version

Properties:
Name Type Default Description
version Number 0 The SDB header / data format version used with coded binary data.
Source:

(readonly) bin

Properties:
Name Type Default Description
bin Buffer null The native binary Buffer containing the SDB associated with this instance.
Source:

(readonly) data

Properties:
Name Type Default Description
data Array null The native JavaScript indexed array containing the SDB associated with this instance.
Source:

Methods

(static) validateEntityObject(entityObj) → {null|String}

Validates a version 0 SDB entity object to ensure that there are no invalid or missing data properties.
Parameters:
Name Type Description
entityObj Object The entity object to validate.
Source:
Returns:
A null is returned if all validation passed, otherwise a string is returned describing the validation failure.
Type
null | String

bufferToBase85(dataBuff, useDelimitersopt) → {String}

Encodes a binary Buffer to a Base85 / Ascii85 string.
Parameters:
Name Type Attributes Default Description
dataBuff Buffer The binary buffer to encode.
useDelimiters Boolean <optional>
true If true, the Base85 <~ .. ~> bookend delimiters are included with the encoded string, otherwise the string is returned without them.
Source:
Returns:
The Base85 / Ascii85 encoded string representation of the dataBuff Buffer.
Type
String

decode(SDBData, encodingopt, processPipeopt) → {Promise}

Decodes the supplied SDB data and assigns it to the data and bin properties if successful.
Parameters:
Name Type Attributes Default Description
SDBData String | Array | Buffer The data to decode. If this is a string, it is decoded using either the detected encoding method or the one specified by the encoding parameter. If this is an array it's assumed to be a native object and assigned to data and data. If this is a Buffer, it's assigned directly to the data and decoded to data.
encoding String <optional>
null The string encoding used for SDBData if it's a string. If SDBData is not a string this parameter is ignored. If processPipe was supplied and was asynchronous (it returned a Promise) then a Promise will also be returned here and resolved when the processPipe resolves.
processPipe function <optional>
null An optional processing function to be applied to the decoded but unparsed SDB binary Buffer before applying the decoding.
Source:
Returns:
An asynchronous promise is returned that resolves when the decoding process has completed.
Type
Promise

encode(encodingopt, processPipeopt) → {Promise}

Encodes the native SDB data object to a compressed base85 or base64 string. The processed binary data is also set to the bin Buffer.
Parameters:
Name Type Attributes Default Description
encoding String <optional>
"base85" The desired data encoding to use, either "base85" or "base64".
processPipe function <optional>
null An optional processing function to be applied to the SDB binary Buffer before applying the encoding. If the referenced function is asynchronous (it returns a Promise), then This function will also return a Promise that will resolve when the processPipe has resolved, otherwise this function will be trated as a synchronous inline function.
Source:
Returns:
An asynchronous promise is returned that resolves withthe SDB data in the desired encoding.
Type
Promise