{"_id":"cbor-sync","_rev":"4576767","name":"cbor-sync","description":"CBOR encode/decode (synchronous, semantic, browser-compatible)","dist-tags":{"latest":"1.0.4"},"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"},{"name":"thegecko","email":""}],"time":{"modified":"2026-04-10T15:45:16.000Z","created":"2014-02-27T14:20:57.664Z","1.0.4":"2019-05-09T09:54:05.316Z","1.0.3":"2018-09-13T18:25:33.084Z","1.0.2":"2014-06-19T17:10:05.875Z","0.0.4":"2014-06-16T17:47:11.578Z","0.0.1":"2014-02-27T14:25:13.236Z","0.0.0":"2014-02-27T14:20:57.664Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/ARMmbed/cbor-sync.git"},"versions":{"1.0.4":{"name":"cbor-sync","version":"1.0.4","description":"CBOR encode/decode (synchronous, semantic, browser-compatible)","homepage":"https://github.com/ARMmbed/cbor-sync","bugs":{"url":"https://github.com/ARMmbed/cbor-sync/issues"},"keywords":["cbor"],"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"},{"name":"thegecko","email":""}],"main":"main.js","scripts":{"test":"grunt mochaTest"},"devDependencies":{"grunt-cli":"~0.1.9","grunt":"~0.4.1","chai":"~1.8.1","grunt-mocha-test":"~0.7.0"},"repository":{"type":"git","url":"git+https://github.com/ARMmbed/cbor-sync.git"},"license":{"type":"MIT","url":"https://raw.github.com/ARMmbed/cbor-sync/master/LICENSE.txt"},"dependencies":{},"gitHead":"35fdf44ce469ec34b7985f8463c806876fdb8d31","_id":"cbor-sync@1.0.4","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"thegecko","email":"npm@thegecko.org"},"dist":{"shasum":"5a11a1ab75c2a14d1af1b237fd84aa8c1593662f","size":8530,"noattachment":false,"key":"/cbor-sync/-/cbor-sync-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/cbor-sync/download/cbor-sync-1.0.4.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cbor-sync_1.0.4_1557395645135_0.8460586782033104"},"_hasShrinkwrap":false,"publish_time":1557395645316,"_cnpm_publish_time":1557395645316,"_cnpmcore_publish_time":"2021-12-16T19:36:33.368Z"},"1.0.3":{"name":"cbor-sync","version":"1.0.3","description":"CBOR encode/decode (synchronous, semantic, browser-compatible)","homepage":"https://github.com/ARMmbed/cbor-sync","bugs":{"url":"https://github.com/ARMmbed/cbor-sync/issues"},"keywords":["cbor"],"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"},{"name":"thegecko","email":""}],"main":"main.js","scripts":{"test":"grunt mochaTest"},"devDependencies":{"grunt-cli":"~0.1.9","grunt":"~0.4.1","chai":"~1.8.1","grunt-mocha-test":"~0.7.0"},"repository":{"type":"git","url":"git+https://github.com/ARMmbed/cbor-sync.git"},"license":{"type":"MIT","url":"https://raw.github.com/ARMmbed/cbor-sync/master/LICENSE.txt"},"dependencies":{},"gitHead":"0b3dcad537433f4099562dd549681abdb988aa39","_id":"cbor-sync@1.0.3","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"thegecko","email":"npm@thegecko.org"},"dist":{"shasum":"a9107c75b1712c5780f79ad4217145011252563c","size":8358,"noattachment":false,"key":"/cbor-sync/-/cbor-sync-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/cbor-sync/download/cbor-sync-1.0.3.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cbor-sync_1.0.3_1536863132947_0.0348066866841823"},"_hasShrinkwrap":false,"publish_time":1536863133084,"_cnpm_publish_time":1536863133084,"_cnpmcore_publish_time":"2021-12-16T19:36:33.600Z"},"1.0.2":{"name":"cbor-sync","version":"1.0.2","description":"CBOR encode/decode (synchronous, semantic, browser-compatible)","homepage":"https://github.com/ARM-RD/cbor-sync","bugs":{"url":"https://github.com/ARM-RD/cbor-sync/issues"},"keywords":["cbor"],"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"},{"name":"thegecko","email":""}],"main":"main.js","scripts":{"test":"grunt mochaTest"},"devDependencies":{"grunt-cli":"~0.1.9","grunt":"~0.4.1","chai":"~1.8.1","grunt-mocha-test":"~0.7.0"},"repository":{"type":"git","url":"https://github.com/ARM-RD/cbor-sync.git"},"license":{"type":"MIT","url":"https://raw.github.com/ARM-RD/cbor-sync/master/LICENSE.txt"},"dependencies":{},"_id":"cbor-sync@1.0.2","dist":{"shasum":"5429606fb184017aed86ce94344460ef0083486a","size":10165,"noattachment":false,"key":"/cbor-sync/-/cbor-sync-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/cbor-sync/download/cbor-sync-1.0.2.tgz"},"_from":".","_npmVersion":"1.4.0","_npmUser":{"name":"geraintluff","email":"luffgd@gmail.com"},"directories":{},"publish_time":1403197805875,"_hasShrinkwrap":false,"_cnpm_publish_time":1403197805875,"_cnpmcore_publish_time":"2021-12-16T19:36:33.810Z"},"0.0.4":{"name":"cbor-sync","version":"0.0.4","description":"Customisable encode/decode for CBOR data (synchronous)","homepage":"https://github.com/ARM-RD/cbor-sync","bugs":{"url":"https://github.com/ARM-RD/cbor-sync/issues"},"keywords":["cbor"],"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"},{"name":"thegecko","email":""}],"main":"main.js","scripts":{"test":"grunt mochaTest"},"devDependencies":{"grunt-cli":"~0.1.9","grunt":"~0.4.1","chai":"~1.8.1","grunt-mocha-test":"~0.7.0"},"repository":{"type":"git","url":"https://github.com/ARM-RD/cbor-sync.git"},"license":{"type":"MIT","url":"https://raw.github.com/ARM-RD/cbor-sync/master/LICENSE.txt"},"dependencies":{},"_id":"cbor-sync@0.0.4","dist":{"shasum":"1eca2cff5474a2b47fb1ff113f64b82cdd737b2c","size":9450,"noattachment":false,"key":"/cbor-sync/-/cbor-sync-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/cbor-sync/download/cbor-sync-0.0.4.tgz"},"_from":".","_npmVersion":"1.4.0","_npmUser":{"name":"geraintluff","email":"luffgd@gmail.com"},"directories":{},"publish_time":1402940831578,"_hasShrinkwrap":false,"_cnpm_publish_time":1402940831578,"_cnpmcore_publish_time":"2021-12-16T19:36:33.992Z"},"0.0.1":{"name":"cbor-sync","version":"0.0.1","description":"Customisable encode/decode for CBOR data (synchronous)","keywords":["cbor"],"main":"main.js","scripts":{"test":"grunt mochaTest"},"devDependencies":{"grunt":"~0.4.1","chai":"~1.8.1","grunt-mocha-test":"~0.7.0"},"license":{"type":"MIT","url":"https://raw.github.com/ARM-RD/cbor-sync/master/LICENSE.txt"},"dependencies":{},"_id":"cbor-sync@0.0.1","dist":{"shasum":"f1abb3ea3e548e2da1858b46dbe353daacb47ac5","size":8017,"noattachment":false,"key":"/cbor-sync/-/cbor-sync-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/cbor-sync/download/cbor-sync-0.0.1.tgz"},"_from":".","_npmVersion":"1.4.0","_npmUser":{"name":"geraintluff","email":"luffgd@gmail.com"},"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"},{"name":"thegecko","email":""}],"directories":{},"publish_time":1393511113236,"_hasShrinkwrap":false,"_cnpm_publish_time":1393511113236,"_cnpmcore_publish_time":"2021-12-16T19:36:34.524Z"},"0.0.0":{"name":"cbor-sync","version":"0.0.0","description":"Encode/decode CBOR data (synchronously)","main":"main.js","scripts":{"test":"grunt mochaTest"},"devDependencies":{"grunt":"~0.4.1","chai":"~1.8.1","grunt-mocha-test":"~0.7.0"},"license":{"type":"MIT","url":"https://raw.github.com/ARM-RD/cbor-sync/master/LICENSE.txt"},"dependencies":{},"_id":"cbor-sync@0.0.0","dist":{"shasum":"885d48411e03400c81fc57246fb02ff38a025218","size":8007,"noattachment":false,"key":"/cbor-sync/-/cbor-sync-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/cbor-sync/download/cbor-sync-0.0.0.tgz"},"_from":".","_npmVersion":"1.4.0","_npmUser":{"name":"geraintluff","email":"luffgd@gmail.com"},"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"},{"name":"thegecko","email":""}],"directories":{},"publish_time":1393510857664,"_hasShrinkwrap":false,"_cnpm_publish_time":1393510857664,"_cnpmcore_publish_time":"2021-12-16T19:36:34.342Z"}},"readme":"# Encode/decode CBOR\n\n[![Build Status](https://travis-ci.org/ARMmbed/cbor-sync.svg?branch=master)](https://travis-ci.org/ARMmbed/cbor-sync) [![NPM version](https://badge.fury.io/js/cbor-sync.png)](http://badge.fury.io/js/cbor-sync)\n\nThis package provides an extensible CBOR encoder/decoder.\n\n## Usage\n\n```javascript\nvar CBOR = require('cbor-sync');\n\nvar encodedBuffer = CBOR.encode({hello: 'world'});\nvar decodedObject = CBOR.decode(encodedBuffer);\n```\n\n## `toCBOR()`\n\nMuch like the `toJSON()` method, which allows objects to provide a replacement representation for encoding, this package checks for a `toCBOR()` method.\n\nNote that this step happens *after* any semantic-tagging/-replacement step, so a custom semantic encoder will always override an objects built-in `toCBOR()` method.\n\n## Semantic extensions\n\nCBOR provides a limited set of basic types (similar to JSON), but provides semantic tagging (optional for both encoder/decoder) that lets you annotate parts of the data so they can be decoded appropriately.\n\nHere is an example (from this module) for encoding Date objects as ISO strings:\n\n```javascript\n// 0 is the CBOR semantic tag number for date/time strings: https://tools.ietf.org/html/rfc7049#section-2.4\nCBOR.addSemanticEncode(0, function (data) {\n\tif (data instanceof Date) {\n\t\treturn data.toISOString();\n\t}\n});\nCBOR.addSemanticDecode(0, function (dateString) {\n\treturn new Date(dateString);\n});\n```\n\n## Known issues\n\n* All floats encoded as 64-bit, regardless of whether they strictly need to be\n","_attachments":{},"homepage":"https://github.com/ARMmbed/cbor-sync","bugs":{"url":"https://github.com/ARMmbed/cbor-sync/issues"},"license":{"type":"MIT","url":"https://raw.github.com/ARMmbed/cbor-sync/master/LICENSE.txt"}}