{"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"}],"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","tarball":"http://registry-npm.ywwl.com/cbor-sync/download/cbor-sync-1.0.2.tgz","integrity":"sha512-Awd1Zeb4zu9bIc3AkK8zkG0y/OjgGGK3yz3EHiwJh1XgkjPoDvAqjlsKZnuhNWJ3jhXQE7cmJG1GGypLbCeh9w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCkq7lW0jQniS4mRGlzteCJcWW+tLPtVNr5pwN+rymoZwIgUfCsS44IxShaGG1MgVOSkvXcTc3wcKmNHZltaDBh2/w="}],"size":10165,"noattachment":false,"key":"/cbor-sync/-/cbor-sync-1.0.2.tgz"},"_from":".","_npmVersion":"1.4.0","_npmUser":{"name":"geraintluff","email":"luffgd@gmail.com"},"directories":{},"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","publish_time":1403197805875,"_cnpm_publish_time":1403197805875,"dist-tags":{"latest":"1.0.4"}}