SharedValueEncoder

SharedValueEncoder

Implement value sharing.

Constructor

new SharedValueEncoder()

Source:
See:
  • cbor.schmorp.de/value-sharing

Methods

clearRecording()

Description:
  • Remove the existing recording and start over. Do this between encoding pairs.
Source:

stopRecording()

Description:
  • Between encoding runs, stop recording, and start outputing correct tags.
Source:

(static) encode(…objs) → {Buffer}

Description:
  • Encode one or more JavaScript objects, and return a Buffer containing the CBOR bytes.
Source:
Parameters:
Name Type Attributes Description
objs any <repeatable>
The objects to encode.
Returns:
The encoded objects.
Type
Buffer

(static) encodeAsync(obj, options) → {Promise.<Buffer>}

Description:
  • Encode one JavaScript object using the given options in a way that is more resilient to objects being larger than the highWaterMark number of bytes. As with the other static encode functions, this will still use a large amount of memory. Use a stream-based approach directly if you need to process large and complicated inputs.
Source:
Parameters:
Name Type Description
obj any The object to encode.
options
Returns:
A promise for the encoded buffer.
Type
Promise.<Buffer>

(static) encodeCanonical(…objs) → {Buffer}

Description:
  • Encode one or more JavaScript objects canonically (slower!), and return a Buffer containing the CBOR bytes.
Source:
Parameters:
Name Type Attributes Description
objs any <repeatable>
The objects to encode.
Throws:
Always. This combination doesn't work at the moment.
Type
Error
Returns:
Never.
Type
Buffer

(static) encodeOne(obj, options) → {Buffer}

Description:
  • Encode one JavaScript object using the given options.
Source:
Parameters:
Name Type Description
obj any The object to encode.
options
Returns:
The encoded objects.
Type
Buffer