Class: Encoder

Defined in: src/encoder.coffee
Inherits: stream.Transform

Overview

Transform JavaScript values into CBOR bytes. The Writable side of the stream is in object mode.

Class Method Summary

Instance Method Summary

Class Method Details

. (void) encode(objs...)

Encode one or more JavaScript objects, and return a Buffer containing the CBOR bytes.

Parameters:

  • objs... ( Object+ ) the objects to encode

Constructor Details

# (void) constructor(options = {})

Create an encoder

Parameters:

  • options ( Object ) options for the encoder

Options Hash: (options):

  • genTypes ( Array ) array of pairs of type, function(Encoder) for semantic types to be encoded. (default: [Array, arrayFunc, Date, dateFunc, Buffer, bufferFunc, RegExp, regexFunc, url.Url, urlFunc, bignumber, bignumberFunc]

Instance Method Details

# (function(Encoder)) addSemanticType(type, fun)

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

Returns:

  • ( function(Encoder) ) — if this type already exists in the semantic type list, replace that function with the new one, and return the old one. Return null if this is a new type.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: