How to use the cbor/lib/utils.guessEncoding 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) {

cbor

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

MIT
Latest version published 3 months ago

Package Health Score

78 / 100
Full package analysis