{"_id":"@dfinity/cbor","_rev":"18-d088e28c397c0d7b8536c461475cc392","name":"@dfinity/cbor","dist-tags":{"latest":"0.2.3"},"versions":{"0.1.0":{"name":"@dfinity/cbor","version":"0.1.0","keywords":["cbor","data-format","encoding","decoding","serialization","deserialization"],"author":{"name":"DFINITY Stiftung"},"license":"Apache-2.0","_id":"@dfinity/cbor@0.1.0","maintainers":[{"name":"dayyildiz","email":"dominik.ayyildiz@dfinity.org"},{"name":"eric-swanson-dfinity","email":"eric.swanson@dfinity.org"},{"name":"krpeacock","email":"kylpeacock@gmail.com"},{"name":"npm-dfinity-org","email":"npm@dfinity.org"},{"name":"bitdivine","email":"bitdivine69@gmail.com"},{"name":"ielashi","email":"diner-rodding@ic8.org"},{"name":"keplervital","email":"kepler.vital@gmail.com"},{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},{"name":"dfn_wndlng","email":"jan.wendling@dfinity.org"},{"name":"dsarlis","email":"dimitrios.sarlis@dfinity.org"},{"name":"ihor_dfinity","email":"ihor.verkhohliad@dfinity.org"},{"name":"dfn-it-owner","email":"itowner@dfinity.org"}],"homepage":"https://dfinity.github.io/cbor-js","bugs":{"url":"https://github.com/dfinity/cbor-js/issues"},"dist":{"shasum":"001d5f1cf4a309f37a548529a1776f24ebcca9ce","tarball":"https://registry.npmjs.org/@dfinity/cbor/-/cbor-0.1.0.tgz","fileCount":19,"integrity":"sha512-Qjq1iOMKd/b+Okz4iQISPYZVipiheEcm9k+Xa5MKbkENWYs//KBiUyfPf0PJ7b8XLZnXY4de+gYJs5buf4rRVA==","signatures":[{"sig":"MEYCIQDRqvVd6fsyACaagvmrhXgtiHbhJ0tfdDvjmZyIu/QlkQIhAOJq0qujLhqOlrUF+guyCKr8dNK19PEx0au0LqweQj+k","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":89694},"main":"./dist/cbor.umd.js","types":"./dist/index.d.ts","module":"./dist/cbor.mjs","exports":{".":{"types":{"default":"./dist/index.d.ts"},"import":"./dist/cbor.mjs","require":"./dist/cbor.umd.js"}},"gitHead":"48d1c9241c2e6ae3a7fb433031e8e773a3fb202c","scripts":{"test":"vitest run --run","bench":"vitest bench --run","build":"vite build && tsc -p ./tsconfig.types.json","tsdoc":"tsdoc --src=src/*,src/encode/*,src/decode/* && prettier --write README.md","format":"prettier --write .","test:watch":"vitest watch","format:check":"prettier --check .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},"repository":{"url":"git+https://github.com/dfinity/cbor-js.git","type":"git"},"_npmVersion":"10.9.2","description":"A small implementation of Concise Binary Object Representation (CBOR) in pure JavaScript.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39","devDependencies":{"borc":"^3.0.0","vite":"^6.3.5","cbor-x":"^1.6.0","vitest":"3.1.4","prettier":"^3.5.3","typescript":"^5.8.3","@types/node":"^22.15.21","simple-cbor":"^0.4.1","tsdoc-markdown":"^1.2.0","vite-plugin-checker":"^0.9.3"},"_npmOperationalInternal":{"tmp":"tmp/cbor_0.1.0_1748343312386_0.8155216808862638","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@dfinity/cbor","version":"0.2.0","keywords":["cbor","data-format","encoding","decoding","serialization","deserialization"],"author":{"name":"DFINITY Stiftung"},"license":"Apache-2.0","_id":"@dfinity/cbor@0.2.0","maintainers":[{"name":"dayyildiz","email":"dominik.ayyildiz@dfinity.org"},{"name":"eric-swanson-dfinity","email":"eric.swanson@dfinity.org"},{"name":"krpeacock","email":"kylpeacock@gmail.com"},{"name":"npm-dfinity-org","email":"npm@dfinity.org"},{"name":"bitdivine","email":"bitdivine69@gmail.com"},{"name":"ielashi","email":"diner-rodding@ic8.org"},{"name":"keplervital","email":"kepler.vital@gmail.com"},{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},{"name":"dfn_wndlng","email":"jan.wendling@dfinity.org"},{"name":"dsarlis","email":"dimitrios.sarlis@dfinity.org"},{"name":"ihor_dfinity","email":"ihor.verkhohliad@dfinity.org"},{"name":"dfn-it-owner","email":"itowner@dfinity.org"}],"homepage":"https://dfinity.github.io/cbor-js","bugs":{"url":"https://github.com/dfinity/cbor-js/issues"},"dist":{"shasum":"778ba616b71765ce4e7b7151d576d3390a60a2aa","tarball":"https://registry.npmjs.org/@dfinity/cbor/-/cbor-0.2.0.tgz","fileCount":19,"integrity":"sha512-xD4ja+hMYjJCIOJjmylT2Dd4TH7GDhrrtuyVJhxONAUjyfqVhfQYCxAMUUJOcJGoybxDg+ERG0nii0UNa2nu7A==","signatures":[{"sig":"MEQCIE/g797rWzj3NdW22FyWzcb8mvNrReHv3Cb8WiSwvUIQAiBEp4fqMAIrMVdLmeqEiCtgwZpfKWnxMb1YTaItnQ4QpA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":93742},"main":"./dist/cbor.umd.js","types":"./dist/index.d.ts","module":"./dist/cbor.mjs","exports":{".":{"types":{"default":"./dist/index.d.ts"},"import":"./dist/cbor.mjs","require":"./dist/cbor.umd.js"}},"gitHead":"58e45776cde3b452cb180452e19cd57f3da36491","scripts":{"test":"vitest run --run","bench":"vitest bench --run","build":"vite build && tsc -p ./tsconfig.types.json","tsdoc":"tsdoc --src=src/*,src/encode/*,src/decode/* && prettier --write README.md","format":"prettier --write .","test:watch":"vitest watch","format:check":"prettier --check .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},"repository":{"url":"git+https://github.com/dfinity/cbor-js.git","type":"git"},"_npmVersion":"10.9.2","description":"A small implementation of Concise Binary Object Representation (CBOR) in pure JavaScript.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39","devDependencies":{"borc":"^3.0.0","vite":"^6.3.5","cbor-x":"^1.6.0","vitest":"3.1.4","prettier":"^3.5.3","typescript":"^5.8.3","@types/node":"^22.15.21","simple-cbor":"^0.4.1","tsdoc-markdown":"^1.2.0","vite-plugin-checker":"^0.9.3"},"_npmOperationalInternal":{"tmp":"tmp/cbor_0.2.0_1748367995753_0.5964496278463314","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@dfinity/cbor","version":"0.2.1","keywords":["cbor","data-format","encoding","decoding","serialization","deserialization"],"author":{"name":"DFINITY Stiftung"},"license":"Apache-2.0","_id":"@dfinity/cbor@0.2.1","maintainers":[{"name":"dayyildiz","email":"dominik.ayyildiz@dfinity.org"},{"name":"eric-swanson-dfinity","email":"eric.swanson@dfinity.org"},{"name":"krpeacock","email":"kylpeacock@gmail.com"},{"name":"npm-dfinity-org","email":"npm@dfinity.org"},{"name":"bitdivine","email":"bitdivine69@gmail.com"},{"name":"ielashi","email":"diner-rodding@ic8.org"},{"name":"keplervital","email":"kepler.vital@gmail.com"},{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},{"name":"dfn_wndlng","email":"jan.wendling@dfinity.org"},{"name":"dsarlis","email":"dimitrios.sarlis@dfinity.org"},{"name":"ihor_dfinity","email":"ihor.verkhohliad@dfinity.org"},{"name":"dfn-it-owner","email":"itowner@dfinity.org"}],"homepage":"https://dfinity.github.io/cbor-js","bugs":{"url":"https://github.com/dfinity/cbor-js/issues"},"dist":{"shasum":"ee5c48a82e3a6c9e3b818e1af2d46f36562ea4d6","tarball":"https://registry.npmjs.org/@dfinity/cbor/-/cbor-0.2.1.tgz","fileCount":19,"integrity":"sha512-VWoInejxqXUhiOMKoDULfO7VVzatR+SuyBHobNAFGk1WwpLwT0SVp5FKJQA9HvoEuRsgVNuA2z4S59708wOR0A==","signatures":[{"sig":"MEUCIQDCVBFoxReOxU59MwZoAXyc6oukbuXcTffUD32DaqKoFQIgLMZVDkYjjpl/hQU2Fy1PldfcgQRoIbM7YiRLazS2+4A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":94761},"main":"./dist/cbor.umd.js","types":"./dist/index.d.ts","module":"./dist/cbor.mjs","exports":{".":{"types":{"default":"./dist/index.d.ts"},"import":"./dist/cbor.mjs","require":"./dist/cbor.umd.js"}},"gitHead":"ebb18724be20ca6a1fed666cc103974f16768e83","scripts":{"test":"vitest run --run","bench":"vitest bench --run","build":"vite build && tsc -p ./tsconfig.types.json","tsdoc":"tsdoc --src=src/*,src/encode/*,src/decode/* && prettier --write README.md","format":"prettier --write .","test:watch":"vitest watch","format:check":"prettier --check .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},"repository":{"url":"git+https://github.com/dfinity/cbor-js.git","type":"git"},"_npmVersion":"10.9.2","description":"A small implementation of Concise Binary Object Representation (CBOR) in pure JavaScript.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39","devDependencies":{"borc":"^3.0.0","vite":"^6.3.5","cbor-x":"^1.6.0","vitest":"3.1.4","prettier":"^3.5.3","typescript":"^5.8.3","@types/node":"^22.15.21","simple-cbor":"^0.4.1","tsdoc-markdown":"^1.2.0","vite-plugin-checker":"^0.9.3"},"_npmOperationalInternal":{"tmp":"tmp/cbor_0.2.1_1748384568818_0.22708138997600913","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@dfinity/cbor","version":"0.2.2","keywords":["cbor","data-format","encoding","decoding","serialization","deserialization"],"author":{"name":"DFINITY Stiftung"},"license":"Apache-2.0","_id":"@dfinity/cbor@0.2.2","maintainers":[{"name":"dayyildiz","email":"dominik.ayyildiz@dfinity.org"},{"name":"eric-swanson-dfinity","email":"eric.swanson@dfinity.org"},{"name":"krpeacock","email":"kylpeacock@gmail.com"},{"name":"npm-dfinity-org","email":"npm@dfinity.org"},{"name":"bitdivine","email":"bitdivine69@gmail.com"},{"name":"ielashi","email":"diner-rodding@ic8.org"},{"name":"keplervital","email":"kepler.vital@gmail.com"},{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},{"name":"dfn_wndlng","email":"jan.wendling@dfinity.org"},{"name":"dsarlis","email":"dimitrios.sarlis@dfinity.org"},{"name":"ihor_dfinity","email":"ihor.verkhohliad@dfinity.org"},{"name":"dfn-it-owner","email":"itowner@dfinity.org"}],"homepage":"https://dfinity.github.io/cbor-js","bugs":{"url":"https://github.com/dfinity/cbor-js/issues"},"dist":{"shasum":"4f31f4f0c1aeb0c8179edd99625180a76a5b43e0","tarball":"https://registry.npmjs.org/@dfinity/cbor/-/cbor-0.2.2.tgz","fileCount":19,"integrity":"sha512-GPJpH73kDEKbUBdUjY80lz7cq9l0vm1h/7ppejPV6O0ZTqCLrYspssYvqjRmK4aNnJ/SKXsP0rg9LYX7zpegaA==","signatures":[{"sig":"MEYCIQDt9s+AYfY4+jS2xlczCHfCA00IVLql78P1ClhFFrR6OQIhAOzd5g41tj7mP2TI+MI2sL9VGXhDUDtcCffFfke1eSiX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":93825},"main":"./dist/cbor.umd.js","types":"./dist/index.d.ts","module":"./dist/cbor.mjs","exports":{".":{"types":{"default":"./dist/index.d.ts"},"import":"./dist/cbor.mjs","require":"./dist/cbor.umd.js"}},"gitHead":"b1ccc4314e74be29be8e97b289eafd991069bba0","scripts":{"test":"vitest run --run","bench":"vitest bench --run","build":"vite build && tsc -p ./tsconfig.types.json","tsdoc":"tsdoc --src=src/*,src/encode/*,src/decode/* && prettier --write README.md","format":"prettier --write .","test:watch":"vitest watch","format:check":"prettier --check .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"nathan.mcgrath.dfinity","actor":{"name":"nathan.mcgrath.dfinity","type":"user","email":"nathan.mcgrath@dfinity.org"},"email":"nathan.mcgrath@dfinity.org"},"repository":{"url":"git+https://github.com/dfinity/cbor-js.git","type":"git"},"_npmVersion":"10.9.2","description":"A small implementation of Concise Binary Object Representation (CBOR) in pure JavaScript.","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39","devDependencies":{"borc":"^3.0.0","vite":"^6.3.5","cbor-x":"^1.6.0","vitest":"3.1.4","prettier":"^3.5.3","typescript":"^5.8.3","@types/node":"^22.15.21","simple-cbor":"^0.4.1","tsdoc-markdown":"^1.2.0","vite-plugin-checker":"^0.9.3"},"_npmOperationalInternal":{"tmp":"tmp/cbor_0.2.2_1750173866424_0.030052304666573493","host":"s3://npm-registry-packages-npm-production"}},"0.2.3":{"name":"@dfinity/cbor","version":"0.2.3","keywords":["cbor","data-format","encoding","decoding","serialization","deserialization"],"author":{"name":"DFINITY Stiftung"},"license":"Apache-2.0","_id":"@dfinity/cbor@0.2.3","maintainers":[{"name":"dayyildiz","email":"dominik.ayyildiz@dfinity.org"},{"name":"antonioventilii-dfinity","email":"antonio.ventilii@dfinity.org"},{"name":"npm-dfinity-org","email":"npm@dfinity.org"},{"name":"dfn_wndlng","email":"jan.wendling@dfinity.org"},{"name":"ielashi","email":"islam@elashi.me"},{"name":"dfn-it-owner","email":"itowner@dfinity.org"},{"name":"g.perez","email":"gabriela.perez@dfinity.org"}],"homepage":"https://github.com/dfinity/cbor-js#readme","bugs":{"url":"https://github.com/dfinity/cbor-js/issues"},"dist":{"shasum":"201c4234c2368fb63d46422d1dae4aeb1cb9ebac","tarball":"https://registry.npmjs.org/@dfinity/cbor/-/cbor-0.2.3.tgz","fileCount":19,"integrity":"sha512-5GX+9tAf29r94Pxv8nCzrv2/t+AkOfem/c/G61+FA2Wadq7THvc5cvr/AVLH0LpukVfNSWRRHvl1fkCdiB9MMQ==","signatures":[{"sig":"MEUCIHMjOOx8Jdsc6hT3lo+bnSUkiHhQF0HkFR4xKf+Jr/w8AiEA1NJLb/aD2uWMVRrufIIYCiyzpihL/5oB4SqlfzL0ev8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@dfinity%2fcbor@0.2.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":94033},"main":"./dist/cbor.umd.js","types":"./dist/index.d.ts","module":"./dist/cbor.mjs","exports":{".":{"types":{"default":"./dist/index.d.ts"},"import":"./dist/cbor.mjs","require":"./dist/cbor.umd.js"}},"gitHead":"e6182be349d377d37071c7e9bae1a48ec1f396ee","scripts":{"test":"vitest run --run","bench":"vitest bench --run","build":"vite build && tsc -p ./tsconfig.types.json","tsdoc":"tsdoc --src=src/*,src/encode/*,src/decode/* && prettier --write README.md","format":"prettier --write .","test:watch":"vitest watch","format:check":"prettier --check .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e1385be5-8b08-4b38-859b-75a32191fcf6"}},"repository":{"url":"git+https://github.com/dfinity/cbor-js.git","type":"git"},"_npmVersion":"11.6.1","description":"A small implementation of Concise Binary Object Representation (CBOR) in pure JavaScript.","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.19.0+sha512.c9fc7236e92adf5c8af42fd5bf1612df99c2ceb62f27047032f4720b33f8eacdde311865e91c411f2774f618d82f320808ecb51718bfa82c060c4ba7c76a32b8","devDependencies":{"borc":"^3.0.0","vite":"^7.2.2","cbor-x":"^1.6.0","vitest":"4.0.8","prettier":"^3.6.2","typescript":"^5.9.3","@types/node":"^24.10.0","simple-cbor":"^0.4.1","tsdoc-markdown":"^1.4.1","vite-plugin-checker":"^0.11.0"},"_npmOperationalInternal":{"tmp":"tmp/cbor_0.2.3_1776934203092_0.8436103042080243","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-05-27T10:55:12.308Z","modified":"2026-10-05T08:12:57.196Z","0.1.0":"2025-05-27T10:55:12.583Z","0.2.0":"2025-05-27T17:46:35.987Z","0.2.1":"2025-05-27T22:22:49.025Z","0.2.2":"2025-06-17T15:24:26.595Z","0.2.3":"2026-04-23T08:50:03.229Z"},"bugs":{"url":"https://github.com/dfinity/cbor-js/issues"},"author":{"name":"DFINITY Stiftung"},"license":"Apache-2.0","homepage":"https://github.com/dfinity/cbor-js#readme","keywords":["cbor","data-format","encoding","decoding","serialization","deserialization"],"repository":{"url":"git+https://github.com/dfinity/cbor-js.git","type":"git"},"description":"A small implementation of Concise Binary Object Representation (CBOR) in pure JavaScript.","maintainers":[{"email":"dominik.ayyildiz@dfinity.org","name":"dayyildiz"},{"email":"npm@dfinity.org","name":"npm-dfinity-org"},{"email":"itowner@dfinity.org","name":"dfn-it-owner"}],"readme":"# CBOR encoder/decoder\n\n[![NPM Version](https://img.shields.io/npm/v/%40dfinity%2Fcbor)](https://www.npmjs.com/package/@dfinity/cbor)\n![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/%40dfinity%2Fcbor)\n\n[![Test](https://github.com/dfinity/cbor-js/actions/workflows/test.yml/badge.svg)](https://github.com/dfinity/cbor-js/actions/workflows/test.yml)\n[![Lint](https://github.com/dfinity/cbor-js/actions/workflows/lint.yml/badge.svg)](https://github.com/dfinity/cbor-js/actions/workflows/lint.yml)\n\nA small implementation of Concise Binary Object Representation (CBOR) in pure JavaScript.\n\n> Note: this package is not 100% compatible with the [CBOR specification](https://www.rfc-editor.org/rfc/rfc8949.html). See the [Not implemented](#not-implemented) section for more details.\n\n## Installation\n\nUsing `npm`:\n\n```bash\nnpm install @dfinity/cbor\n```\n\nUsing `pnpm`:\n\n```bash\npnpm add @dfinity/cbor\n```\n\nUsing `yarn`:\n\n```bash\nyarn add @dfinity/cbor\n```\n\n## Usage\n\nSimple:\n\n```ts\nimport { encode, decode } from '@dfinity/cbor';\n\nconst value = true;\nconst encoded = encode(value); // returns `Uint8Array [245]` (which is \"F5\" in hex)\nconst decoded = decode(encoded); // returns `true`\n```\n\nWith replacer/reviver:\n\n```ts\nimport { encode, decode, type Replacer, type Reviver } from '@dfinity/cbor';\n\nconst value = { a: 1, b: 2 };\n\n// Encoding with replacer\nconst replacer: Replacer = val => (typeof val === 'number' ? val * 2 : val);\nconst result = encode(value, replacer);\ndecode(result); // { a: 2, b: 4 }\n\n// Decoding with reviver\nconst bytes = encode(value);\nconst reviver: Reviver = val => (typeof val === 'number' ? val * 2 : val);\ndecode(bytes, reviver); // { a: 2, b: 4 }\n```\n\n## API\n\n<!-- TSDOC_START -->\n\n## :toolbox: Functions\n\n- [decode](#gear-decode)\n- [encode](#gear-encode)\n- [encodeWithSelfDescribedTag](#gear-encodewithselfdescribedtag)\n\n### :gear: decode\n\nDecodes a CBOR byte array into a value.\nSee {@link Reviver} for more information.\n\n| Function | Type                                                                                                    |\n| -------- | ------------------------------------------------------------------------------------------------------- |\n| `decode` | `<T extends unknown = any>(input: Uint8Array<ArrayBufferLike>, reviver?: Reviver<T> or undefined) => T` |\n\nParameters:\n\n- `input`: - The CBOR byte array to decode.\n- `reviver`: - A function that can be used to manipulate the decoded value.\n\nExamples:\n\nSimple\n\n```ts\nconst value = true;\nconst encoded = encode(value); // returns `Uint8Array [245]` (which is \"F5\" in hex)\nconst decoded = decode(encoded); // returns `true`\n```\n\nReviver\n\n```ts\nconst bytes = ...; // Uint8Array corresponding to the CBOR encoding of `{ a: 1, b: 2 }`\nconst reviver: Reviver = val => (typeof val === 'number' ? val * 2 : val);\ndecode(bytes, reviver); // returns `{ a: 2, b: 4 }`\n```\n\n### :gear: encode\n\nEncodes a value into a CBOR byte array.\n\n| Function | Type                                                                                                 |\n| -------- | ---------------------------------------------------------------------------------------------------- |\n| `encode` | `<T = any>(value: CborValue<T>, replacer?: Replacer<T> or undefined) => Uint8Array<ArrayBufferLike>` |\n\nParameters:\n\n- `value`: - The value to encode.\n- `replacer`: - A function that can be used to manipulate the input before it is encoded.\n\nExamples:\n\nSimple\n\n```ts\nconst value = true;\nconst encoded = encode(value); // returns `Uint8Array [245]` (which is \"F5\" in hex)\n```\n\nReplacer\n\n```ts\nconst replacer: Replacer = val => (typeof val === 'number' ? val * 2 : val);\nencode({ a: 1, b: 2 }, replacer); // returns the Uint8Array corresponding to the CBOR encoding of `{ a: 2, b: 4 }`\n```\n\n### :gear: encodeWithSelfDescribedTag\n\nEncodes a value into a CBOR byte array (same as {@link encode}), but prepends the self-described CBOR tag (55799).\n\n| Function                     | Type                                                                                                 |\n| ---------------------------- | ---------------------------------------------------------------------------------------------------- |\n| `encodeWithSelfDescribedTag` | `<T = any>(value: CborValue<T>, replacer?: Replacer<T> or undefined) => Uint8Array<ArrayBufferLike>` |\n\nParameters:\n\n- `value`: - The value to encode.\n- `replacer`: - A function that can be used to manipulate the input before it is encoded.\n\nExamples:\n\n```ts\nconst value = true;\nconst encoded = encodeWithSelfDescribedTag(value); // returns the Uint8Array [217, 217, 247, 245] (which is \"D9D9F7F5\" in hex)\n```\n\n## :wrench: Constants\n\n- [CBOR_SELF_DESCRIBED_TAG](#gear-cbor_self_described_tag)\n- [CBOR_STOP_CODE](#gear-cbor_stop_code)\n- [TOKEN_VALUE_MAX](#gear-token_value_max)\n- [ONE_BYTE_MAX](#gear-one_byte_max)\n- [TWO_BYTES_MAX](#gear-two_bytes_max)\n- [FOUR_BYTES_MAX](#gear-four_bytes_max)\n- [EIGHT_BYTES_MAX](#gear-eight_bytes_max)\n\n### :gear: CBOR_SELF_DESCRIBED_TAG\n\nThe tag number `55799`, the self-described tag for CBOR.\nThe serialization of this tag's head is `0xd9d9f7`.\n\n| Constant                  | Type    |\n| ------------------------- | ------- |\n| `CBOR_SELF_DESCRIBED_TAG` | `55799` |\n\n### :gear: CBOR_STOP_CODE\n\n| Constant         | Type            |\n| ---------------- | --------------- |\n| `CBOR_STOP_CODE` | `unique symbol` |\n\n### :gear: TOKEN_VALUE_MAX\n\n| Constant          | Type |\n| ----------------- | ---- |\n| `TOKEN_VALUE_MAX` | `23` |\n\n### :gear: ONE_BYTE_MAX\n\n| Constant       | Type  |\n| -------------- | ----- |\n| `ONE_BYTE_MAX` | `255` |\n\n### :gear: TWO_BYTES_MAX\n\n| Constant        | Type    |\n| --------------- | ------- |\n| `TWO_BYTES_MAX` | `65535` |\n\n### :gear: FOUR_BYTES_MAX\n\n| Constant         | Type         |\n| ---------------- | ------------ |\n| `FOUR_BYTES_MAX` | `4294967295` |\n\n### :gear: EIGHT_BYTES_MAX\n\nThe maximum value that can be encoded in 8 bytes: `18446744073709551615n`.\n\n| Constant          | Type     |\n| ----------------- | -------- |\n| `EIGHT_BYTES_MAX` | `bigint` |\n\n## :factory: DecodingError\n\n## :factory: EncodingError\n\n## :nut_and_bolt: Enum\n\n- [CborSimpleType](#gear-cborsimpletype)\n- [CborMajorType](#gear-cbormajortype)\n- [CborMinorType](#gear-cborminortype)\n\n### :gear: CborSimpleType\n\n| Property    | Type   | Description |\n| ----------- | ------ | ----------- |\n| `False`     | `0x14` |             |\n| `True`      | `0x15` |             |\n| `Null`      | `0x16` |             |\n| `Undefined` | `0x17` |             |\n| `Break`     | `0x1f` |             |\n\n### :gear: CborMajorType\n\n| Property          | Type | Description |\n| ----------------- | ---- | ----------- |\n| `UnsignedInteger` | `0`  |             |\n| `NegativeInteger` | `1`  |             |\n| `ByteString`      | `2`  |             |\n| `TextString`      | `3`  |             |\n| `Array`           | `4`  |             |\n| `Map`             | `5`  |             |\n| `Tag`             | `6`  |             |\n| `Simple`          | `7`  |             |\n\n### :gear: CborMinorType\n\n| Property     | Type | Description |\n| ------------ | ---- | ----------- |\n| `Value`      | `23` |             |\n| `OneByte`    | `24` |             |\n| `TwoBytes`   | `25` |             |\n| `FourBytes`  | `26` |             |\n| `EightBytes` | `27` |             |\n| `Indefinite` | `31` |             |\n\n<!-- TSDOC_END -->\n\n## Not implemented\n\n- Custom tag encoding/decoding.\n  - Custom tags allow for encoding and decoding of custom types.\n  - We currently don't use this custom tags (although we probably should).\n  - Since we don't directly encode developer provided data (that's encoded by Candid) then we can safely say we don't need the feature.\n- Unit tests for text/byte strings with a length that does not fit in four bytes or less.\n  - The \"length\" of the text string can be encoded with up to 8 bytes, which means the largest possible string length is `18,446,744,073,709,551,615`. The tests cover a string length that's encoded up to four 4 bytes, longer than this and the tests became extremely slow.\n  - The largest number in 4 bytes is `2,147,483,647` which would represent the length of an ~2gb string, which is not possible to fit into a single IC message anyway.\n- Indeterminite length encoding for text and byte strings\n  - To encode a string length longer than the previously mentioned 8 byte limit, a string can be encoded with an \"indeterminate\" length.\n  - Similar to the previous point, this would be impractical for the IC due to message limits.\n\n## Contributing\n\nCheck out the [contribution guidelines](./.github/CONTRIBUTING.md).\n\n### Setup\n\n- Install [pnpm](https://pnpm.io/)\n- Install [commitizen](https://commitizen-tools.github.io/commitizen/)\n- Install [pre-commit](https://pre-commit.com/)\n- Install dependencies:\n  ```bash\n  pnpm install\n  ```\n\n### Running tests\n\n```bash\npnpm test\n```\n\n### Formatting\n\n```bash\npnpm format\n```\n\n### Generating documentation\n\nWe use [tsdoc-markdown](https://github.com/peterpeterparker/tsdoc-markdown) to generate the documentation.\n\nTo update the documentation in the `README.md` file, run:\n\n```bash\npnpm tsdoc\n```\n\n## License\n\nThis project is licensed under the [Apache License 2.0](./LICENSE).\n","readmeFilename":"README.md"}