Create an encoder
The output stream to encode into
Write a BREAK stop code. This is not constrained by any pre-written strucutural context.
this encoder
Encode a value to a CBOR representation.
If a buffer is provided, optional offset & length parameters may be provided to dictate which bytes are to be encoded.
the value to encode
the offset to use if encoding a buffer. Defaults to 0
the length to use if encoding a buffer. Defaults to the length of the buffer
this encoder
Flush the encoded data and empty the internal buffer
the contents of the buffer
Write the header for an array.
Data may be subsequently written. No constraints are applied to subsequent data, i.e the header for a fixed-length array may be immediately followed by a break flag
the length of the array. If not provided, this array will be considered indefinite-length
this encoder
Write the header for an object.
Data may be subsequently written. No constraints are applied to subsequent data, i.e the header for a fixed-length object may be immediately followed by a break flag
the number of keys in the object. If not provided, this object will be considered indefinite-length
this encoder
Write an array to the output stream
the array to encode
Write a Binary value to the output stream
the starting position in the buffer
the number of bytes to write
Write a boolean to the output stream
the boolean to write
Write a break header to the output stream
the header type
Write a Uint8Array to the output stream
the buffer to write
the starting position in the buffer
the number of bytes to write
Write a byte to the output stream
the byte to wryte
Write a double value.
the double value to encode
this encoder
Write null to the output stream
Write a number of any type to the output stream
the number to write
Write an object to the output stream
the object to encode
Write a string to the output stream
the string to write
Write a token to the output stream
the token type
the numeric value associated with the token
Write an unsigned 16 bit integer to the output stream
the integer to write
Write an unsigned 32 bit integer to the output stream
the integer to write
Write an unsigned 64 bit integer to the output stream
the integer to write
Write undefined to the output stream
Copyright © 2025 DiffusionData Ltd. All Rights Reserved.
Encoder to encode values into CBOR