How to use the cbor.Decoder function in cbor

To help you get started, we’ve selected a few cbor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipld / js-ipld-dag-cbor / src / cbor.js View on Github external
exports.unmarshal = (input, opts) => {
  opts = defaults(opts || {}, {
    encoding: cborUtils.guessEncoding(input)
  })

  const dec = new cbor.Decoder(opts)
  const bs = new NoFilter()

  dec.pipe(bs)
  dec.end(input, opts.encoding)

  const res = bs.read()

  function transform (obj) {
    Object.keys(obj).forEach((key) => {
      const val = obj[key]
      // This is safe as we reference the same cbor instance
      // as we used to decode with
      if (val instanceof cbor.Tagged) {
        if (typeof val.value === 'string') {
          obj[key] = {
            [LINK_SYMBOL]: val.value

cbor

Encode and parse data in the Concise Binary Object Representation (CBOR) data format (RFC8949).

MIT
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis