Constructor
new Encoder(optionsopt)
Creates an instance of Encoder.
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
{} | options for the encoder
Properties
|
- Source:
Extends
- stream.Transform
Methods
(static) encode(…objs) → {Buffer}
Encode one or more JavaScript objects, and return a Buffer containing the
CBOR bytes.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
objs |
any |
<repeatable> |
the objects to encode |
- Source:
Returns:
- the encoded objects
- Type
- Buffer
addSemanticType(type, fun) → {encodeFunction}
Add an encoding function to the list of supported semantic types. This is
useful for objects for which you can't add an encodeCBOR method
Parameters:
| Name | Type | Description |
|---|---|---|
type |
any | |
fun |
any |
- Source:
Returns:
- Type
- encodeFunction
pushAny(obj) → {boolean}
Push any supported type onto the encoded stream
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
any |
- Source:
Returns:
true on success
- Type
- boolean