{"name":"@ipld/dag-cbor","version":"1.0.2","keywords":["IPFS"],"author":{"url":"https://www.mikealrogers.com/","name":"Mikeal Rogers","email":"mikeal.rogers@gmail.com"},"license":"MIT","_id":"@ipld/dag-cbor@1.0.2","homepage":"https://github.com/ipld/js-ipld-dag-cbor","bugs":{"url":"https://github.com/ipld/js-ipld-dag-cbor/issues"},"dist":{"shasum":"93204f931907a365b4c04f90d3fe56240e85f087","tarball":"http://registry-npm.ywwl.com/@ipld/dag-cbor/download/@ipld/dag-cbor-1.0.2.tgz","fileCount":7,"integrity":"sha512-F2ZqoXe1NGrBFDKdrOHUcuAy0p0iivI7jIsujbgaykXiKqw6njXMk6l5W5mXStYdc5GF/b9O4Zv77Tw5H+DonQ==","signatures":[{"sig":"MEUCIG+2Vy93wubhv6IjWDmIKtA0NVvJCEcvZDpwoUovLGZ0AiEAn/9IArE/3eNYs8hI/D9NtkxulBclnQ7PhNAY7bL840M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19078,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe67FlCRA9TVsSAnZWagAAq/EQAI5dLjXbzUbQe0NpYZ2A\nJ41REXdP1MhLdPKOedhu62/C9OBdZBJh2RQ/iWUC5btGUmDV5DJ9hGDjs5XR\nQtf8jk7fNQIJ1C30oOukDXzTwdtg/G9Gzfd1NNm4W/Qal9NacG4X4g9LKyd0\nk56IpKnjFvxNB4nBp3MyystwQx2h6KWoBZT7WzvM1D7NWCvPaM2LPFsDECIB\nZm6mP85sYGgo4/BdXfyzPWyJNzjl9ROZ/J5a6LhlDecH8q2xfoMBclhBHj4L\neNLTYqSREXcTvQj64n/xm8riFml0XIObU/ofRo8IOUYBDvaf5ttuSeu08Zr3\nHoW5f7yIFH97je/wv3P2NyBOA3U7O5T7JYVWY907ls3UC9qIXoQWmiiXDwPd\nIjh2mYrx1k5SHnumFV03YxDYtQaJ9evTvkdx6GkybyMKzy3Iiyry/pbYsa9R\nyT6bl2G/v2bCWmR8RJfnbHCoZWzqHUrHQQd6sFyBOPeWwJU3gw5sBiwUxjXA\nT0FCdTuHgjyrZe7ZiYBGuO3McYK/6TBWevW75RyEUra1cGHL3oqLppVX39cU\nz4yeZGva7MygfM/9/qQlPxZt3pPkoPzaAyg+OuzdnwPiBD+aL9HiAXYJTt6p\neQrzAz8fTpgTcdHh0nAr48OM/Itwhrhy2Dm9XSg5Eo0rMk4rjASWmdURdE/g\nS8xt\r\n=9d5D\r\n-----END PGP SIGNATURE-----\r\n","size":5965,"noattachment":false,"key":"/@ipld/dag-cbor/-/@ipld/dag-cbor-1.0.2.tgz"},"main":"src/index.js","type":"module","gitHead":"f038148ed45d322da4a49a6e448d2763308bea49","scripts":{"test":"hundreds mocha test/test-*.js && npm run test:browser","pretest":"standard","coverage":"nyc --reporter=html mocha test/test-*.js && npx st -d coverage -p 8080","test:browser":"polendina --cleanup test/test-*.js"},"_npmUser":{"name":"mikeal","email":"mikeal.rogers@gmail.com"},"repository":{"url":"git+https://github.com/ipld/js-ipld-dag-cbor.git","type":"git"},"_npmVersion":"6.14.4","description":"JS implementation of dag-cbor","directories":{"test":"test"},"_nodeVersion":"12.18.0","dependencies":{"borc":"^2.1.2","is-circular":"^1.0.2"},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^8.0.1","garbage":"0.0.0","hundreds":"0.0.4","standard":"^14.3.4","polendina":"^1.0.0","multiformats":"1.0.7"},"_npmOperationalInternal":{"tmp":"tmp/dag-cbor_1.0.2_1592504676965_0.9551611560080029","host":"s3://npm-registry-packages"},"readme":"# @ipld/dag-cbor <!-- omit in toc -->\n\n[![codecov](https://img.shields.io/codecov/c/github/ipld/js-dag-cbor.svg?style=flat-square)](https://codecov.io/gh/ipld/js-dag-cbor)\n[![CI](https://img.shields.io/github/workflow/status/ipld/js-dag-cbor/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipld/js-dag-cbor/actions/workflows/js-test-and-release.yml)\n\n> JS implementation of DAG-CBOR\n\n## Table of contents <!-- omit in toc -->\n\n- [Install](#install)\n- [Spec](#spec)\n- [License](#license)\n- [Contribute](#contribute)\n\n## Install\n\n```console\n$ npm i @ipld/dag-cbor\n```\n\nThis is the *new* interface meant for use by itself or with `multiformats` and\n`@ipld/block`. It is not used by `js-ipld-format` which is currently\nused in IPFS. That library is [here](https://github.com/ipld/js-ipld-dag-cbor).\n\nUsage:\n\n```javascript\nimport { encode, decode } from '@ipld/dag-cbor'\nimport { CID } from 'multiformats'\n\nconst obj = {\n  x: 1,\n  /* CID instances are encoded as links */\n  y: [2, 3, CID.parse('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4')],\n  z: {\n    a: CID.parse('QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4'),\n    b: null,\n    c: 'string'\n  }\n}\n\nlet data = encode(obj)\nlet decoded = decode(data)\ndecoded.y[0] // 2\nCID.asCID(decoded.z.a) // cid instance\n\n// encode/decode options are exported for use with cborg's encodedLength and decodeFirst\nimport { encodeOptions, decodeOptions } from '@ipld/dag-cbor'\nimport { encodedLength } from 'cborg/length'\nimport { decodeFirst } from 'cborg'\n\n// dag-cbor encoded length of obj in bytes\nconst byteLength = encodedLength(obj, encodeOptions)\nbyteLength // 104\n\n// concatenate two dag-cbor encoded obj\nconst concatenatedData = new Uint8Array(data.length * 2)\nconcatenatedData.set(data)\nconcatenatedData.set(data, data.length)\n\n// returns dag-cbor decoded obj at the beginning of the buffer as well as the remaining bytes\nconst [first, remainder] = decodeFirst(concatenatedData, decodeOptions)\nassert.deepStrictEqual(first, obj)\nassert.deepStrictEqual(remainder, data)\n```\n\n## Spec\n\nThe [`dag-cbor` specification is in the IPLD specs repo](https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-cbor.md).\n\n## License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n## Contribute\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1592504677098,"maintainers":[{"name":"npm-service-account-ipld","email":"npm-service-account+ipld@ipfs.tech"},{"name":"lidel","email":"lidel@lidel.org"},{"name":"alanshaw","email":"alan138@gmail.com"},{"name":"vascosantos","email":"santos.vasco10@gmail.com"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"rvagg","email":"r@va.gg"},{"name":"daviddias","email":"mail@daviddias.me"},{"name":"mikeal","email":"mikeal.rogers@gmail.com"},{"name":"vmx","email":"volker.mische@gmail.com"}],"_cnpm_publish_time":1592504677098,"dist-tags":{"latest":"10.0.2"}}