(add-ext-packer! codec id type packer)
Adds the given packer to the codec, where id
is the identifier for the
msgpack extension ((<= 0 id 255)
), type is the data type for which
to use the packer and packer
is a function that takes a value of
type type
and returns a buffer
in which the value is encoded.
Returns the modified codec.
Adds the given packer to the codec, where `id` is the identifier for the msgpack extension (`(<= 0 id 255)`), type is the data type for which to use the packer and `packer` is a function that takes a value of type `type` and returns a `buffer` in which the value is encoded. Returns the modified codec.
(add-ext-packers! codec id type packer unpacker)
Adds the given pakcer and unpacker to the codec. See add-ext-packer!
and add-ext-unpacker!
for more information.
Adds the given pakcer and unpacker to the codec. See `add-ext-packer!` and `add-ext-unpacker!` for more information.
(add-ext-unpacker! codec id unpacker)
Adds the given unpacker to the codec, where id
is the identifier for the
msgpack extension ((<= 0 id 255)
) and unpacker
is a function that takes
a buffer, and extracts and returns the corresponding value.
Returns the modified codec.
Adds the given unpacker to the codec, where `id` is the identifier for the msgpack extension (`(<= 0 id 255)`) and `unpacker` is a function that takes a buffer, and extracts and returns the corresponding value. Returns the modified codec.
(create-codec & {:as options})
Creates and returns a new codec with the given options.
The options are defined on https://github.com/kawanet/msgpack-lite
and can be defined by keywords, e.g., (create-codec :useraw true)
Creates and returns a new codec with the given options. The options are defined on https://github.com/kawanet/msgpack-lite and can be defined by keywords, e.g., `(create-codec :useraw true)`
(create-decode-transform & {:as options})
Creates a decode transform that can read from another stream (via .pipe
).
An optional codec
can be passed with :codec codec
.
Any object decoded is passed to js->clj
unless :js->clj false
is
passed as option (default is :js->clj true
. If :keywordize-keys true
is passed as option, clojure.walk/keywordize-keys
is applied to
the decoded object, i.e., all keys of maps are replaced by keywords.
Default is :keywordize-keys false
.
Note: decode
is rebound so that any options passed to
create-decode-transform
are automatically passed to any subsequent
call of decode
. Any options passed to recursive calls of decode
overrides prior options (as in merge
).
Creates a decode transform that can read from another stream (via `.pipe`). An optional `codec` can be passed with `:codec codec`. Any object decoded is passed to `js->clj` unless `:js->clj false` is passed as option (default is `:js->clj true`. If `:keywordize-keys true` is passed as option, `clojure.walk/keywordize-keys` is applied to the decoded object, i.e., all keys of maps are replaced by keywords. Default is `:keywordize-keys false`. Note: `decode` is rebound so that any options passed to `create-decode-transform` are automatically passed to any subsequent call of `decode`. Any options passed to recursive calls of `decode` overrides prior options (as in `merge`).
(create-encode-transform & {:as options})
Creates an encode transform that can be piped to another
stream. With options
an optional codec can be defined with
:codec codec
. As with encode
, the symbol
encode
is rebound so that any options passed to
create-encode-transform
are automatically passed to any subsequent
call of encode
, in particular :codec codec
. Any options
passed to recursive calls of encode
overrides prior
options (as in merge
).
Creates an encode transform that can be piped to another stream. With `options` an optional codec can be defined with `:codec codec`. As with `encode`, the symbol `encode` is rebound so that any options passed to `create-encode-transform` are automatically passed to any subsequent call of `encode`, in particular `:codec codec`. Any options passed to recursive calls of `encode` overrides prior options (as in `merge`).
(decode buffer & {:as options})
Decodes the given buffer using msgpack-lite
's decode.
buffer
can be a buffer
or a byte array (e.g., [0x03 0x3f]
).
An optional codec
can be passed with :codec codec
.
Any object decoded is passed to js->clj
unless :js->clj false
is
passed as option (default is :js->clj true
. If :keywordize-keys true
is passed as option, clojure.walk/keywordize-keys
is applied to
the decoded object, i.e., all keys of maps are replaced by keywords.
Default is :keywordize-keys false
.
Note: decode
is rebound so that any options passed to
the initial call are automatically passed to any subsequent call of decode
.
Any options passed to recursive calls of decode
overrides prior options (as in merge
).
Decodes the given buffer using `msgpack-lite`'s decode. `buffer` can be a `buffer` or a byte array (e.g., `[0x03 0x3f]`). An optional `codec` can be passed with `:codec codec`. Any object decoded is passed to `js->clj` unless `:js->clj false` is passed as option (default is `:js->clj true`. If `:keywordize-keys true` is passed as option, `clojure.walk/keywordize-keys` is applied to the decoded object, i.e., all keys of maps are replaced by keywords. Default is `:keywordize-keys false`. Note: `decode` is rebound so that any options passed to the initial call are automatically passed to any subsequent call of `decode`. Any options passed to recursive calls of `decode` overrides prior options (as in `merge`).
(encode value & {:as options})
Encodes the given value using msgpack-lite
's encode.
The encoded value is returned in a buffer
.
An optional codec
can be passed with :codec codec
.
Note: encode
is rebound so that any options passed to
the initial call are automatically passed to any subsequent
call of encode
. Any options passed to recursive calls of
encode
overrides prior options (as in merge
).
Encodes the given value using `msgpack-lite`'s encode. The encoded value is returned in a `buffer`. An optional `codec` can be passed with `:codec codec`. Note: `encode` is rebound so that any options passed to the initial call are automatically passed to any subsequent call of `encode`. Any options passed to recursive calls of `encode` overrides prior options (as in `merge`).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close