Constructor
new Encoder(optionsopt)
Creates an instance of Encoder.
- Source:
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
<optional> |
{} |
options for the encoder
|
Extends
- stream.Transform
Methods
(static) encode(…objs) → {Buffer}
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:
- Type:
-
Buffer
- the encoded objects
(static) encodeCanonical(…objs) → {Buffer}
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 |
Returns:
- Type:
-
Buffer
- the encoded objects
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
- Source:
Parameters:
Name | Type | Description |
---|---|---|
type |
any
|
|
fun |
any
|
Returns:
- Type:
-
encodeFunction
pushAny(obj) → {boolean}
Push any supported type onto the encoded stream
- Source:
Parameters:
Name | Type | Description |
---|---|---|
obj |
any
|
Returns:
- Type:
-
boolean
true on success