{"name":"@ipld/dag-cbor","version":"3.0.0","keywords":["IPFS"],"author":{"url":"https://www.mikealrogers.com/","name":"Mikeal Rogers","email":"mikeal.rogers@gmail.com"},"license":"MIT","_id":"@ipld/dag-cbor@3.0.0","homepage":"https://github.com/ipld/js-dag-cbor","bugs":{"url":"https://github.com/ipld/js-dag-cbor/issues"},"dist":{"shasum":"31e79d3d5e2e27ba8eeec21672710e06e2cd2b39","tarball":"http://registry-npm.ywwl.com/@ipld/dag-cbor/download/@ipld/dag-cbor-3.0.0.tgz","fileCount":10,"integrity":"sha512-s/iL7Gja5fHKGcaOY+1UAZzgzOQcTysisYjCY4GtkYaCgeGeurTrMjHHuRGSREuMJ1JrrZXDdkVuejDJhZTeZw==","signatures":[{"sig":"MEYCIQDcsgasfj3w0ALKTn18w9co2t7uhvhAtlTgacmOUr+vKgIhAOARP2CoISnFTmOpo7NYWIu9qp0nmdURcYmBpwAkTmWi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33557,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBk1CCRA9TVsSAnZWagAAQIAQAIwKwkx8Iew9l+rw345F\nQgSEjjmmeqFBvORZCbGUSg74R7MkkOKePkBu/NUtzSDDmU5NV8Ghxg4VqqW2\nuInWYcphMRiikbnD7q3/R7KM+XsujUvxOzqI30swYJjFia/jf6uGaE+/t09C\no6EL5VPvlixJoqPYaOqxVPZxLdtlZ3EyuHH4Y4aw4L29sQ123WK/5KlpSPpk\niR7ZqaVV7Z0HQxMVLaymKd54UtFQzrWSduXioZkvIpg1FkwSlZMppjHUQHJH\nxKO8VlXmzuaYYa87xAtF/PaQyW+FBjUmk7QH6iId+SjESCV5J+2Wrtg8XAQj\n6MqjhspXRt2OC2/QqwzKfiG1ijUDL7KCoVQvtG7ZcarqEJ8v5kPe2NKnua09\nGuPwZB3ckFPPG/MsqZnnyxhcXNfrMtTAlZgUq/4m6FdtYJUw1zyzBDP9lJry\n7zH+h5xW1pLy2FIvcdHNY30v8fdA2RGJvQ/pQBSA0OslRIO1b319J126yrId\nrE7jNyo3YR+3xezs3Ad78RfjPZcaKzUuu1/0uXJHJKGolFCaarMS7jzUfsCc\nDbnb0ivm/A2filJ7GHLv2JFREhD5juHaRTMlb+Hl9Y+BcpKb/1O/raldLFxJ\nyzE6cKboKufnND2xMBDRXNNmE5pajLOYFe26C6SXG4NhmMG4XLhtKBk0li9X\nVDFz\r\n=acFU\r\n-----END PGP SIGNATURE-----\r\n","size":4925,"noattachment":false,"key":"/@ipld/dag-cbor/-/@ipld/dag-cbor-3.0.0.tgz"},"browser":"./cjs/index.js","exports":{"import":"./esm/index.js","browser":"./esm/index.js","require":"./cjs/index.js"},"scripts":{"lint":"standard","test":"npm run lint && npm run test:node && npm run test:cjs && npm run test:browser","build":"npm_config_yes=true npx ipjs@latest build --tests","publish":"npm_config_yes=true npx ipjs@latest publish","coverage":"c8 --reporter=html mocha test/test-*.js && npx st -d coverage -p 8080","test:cjs":"npm run build && mocha dist/cjs/node-test/test-*.js","test:node":"hundreds mocha test/test-*.js","test:browser":"polendina --cleanup dist/cjs/node-test/test-*.js"},"_npmUser":{"name":"mikeal","email":"mikeal.rogers@gmail.com"},"repository":{"url":"git+https://github.com/ipld/js-dag-cbor.git","type":"git"},"_npmVersion":"6.14.10","description":"JS implementation of dag-cbor","directories":{"test":"test"},"_nodeVersion":"12.20.1","dependencies":{"cborg":"^1.0.3","multiformats":"^4.4.3"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","mocha":"^8.2.1","hundreds":"^0.0.9","standard":"^16.0.3","polendina":"^1.1.0","ipld-garbage":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dag-cbor_3.0.0_1611025730073_0.2603264661419127","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":1611025730241,"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":1611025730241,"dist-tags":{"latest":"10.0.2"}}