{"name":"borc","version":"2.0.0","description":"Encode and parse data in the Concise Binary Object Representation (CBOR) data format (RFC7049).","main":"./src/index.js","repository":{"type":"git","url":"git+https://github.com/dignifiedquire/borc.git"},"homepage":"https://github.com/dignifiedquire/borc.git","browser":{"fs":false},"scripts":{"lint-asm":"asmjs lib/*.asm.js","test":"aegir-test","test:browser":"aegir-test --env browser","test:node":"aegir-test --env node","lint":"aegir-lint","docs":"aegir-docs","release":"aegir-release --docs","release-minor":"aegir-release --type minor --docs","release-major":"aegir-release --type major --docs","build":"aegir-build","coverage":"aegir-coverage","coverage-publish":"aegir-coverage publish","bench":"node benchmarks/index"},"keywords":["coap","cbor","json","asm","asm.js"],"author":{"name":"Friedel Ziegelmayer","email":"dignifiedquire@gmail.com"},"devDependencies":{"aegir":"^9.1.2","asm.js":"github:dherman/asm.js","cbor":"^3.0.0","chai":"^3.5.0","garbage":"0.0.0"},"license":"MIT","dependencies":{"bignumber.js":"~3.0.0","commander":"^2.9","ieee754":"^1.1.8","json-text-sequence":"^0.1"},"engines":{"node":">=4"},"contributors":[{"name":"Benjamin Cabé","email":"kartben@gmail.com"},{"name":"Friedel Ziegelmayer","email":"dignifiedquire@gmail.com"},{"name":"Joe Hildebrand","email":"joe-github@cursive.net"},{"name":"Joe Hildebrand","email":"joe+github@cursive.net"},{"name":"Patrick Gansterer","email":"paroga@paroga.com"},{"name":"Scorpi","email":"cobblebone@gmail.com"},{"name":"greenkeeperio-bot","email":"support@greenkeeper.io"}],"gitHead":"c6341582cefd367daaf5b59505c2c2a4a679683d","bugs":{"url":"https://github.com/dignifiedquire/borc/issues"},"_id":"borc@2.0.0","_shasum":"83637b6228492e9468fa255a7b1315f7a1b1418a","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.2.1","_npmUser":{"name":"dignifiedquire","email":"dignifiedquire@gmail.com"},"dist":{"shasum":"83637b6228492e9468fa255a7b1315f7a1b1418a","tarball":"http://registry-npm.ywwl.com/borc/download/borc-2.0.0.tgz","integrity":"sha512-v3ObO3ze0VuM8Mq6GRbUunL8JFE+UJ3poODTmqX4HmjSA201/aVqWPKHCTKGx/OAWwqE6Pt4Q6J6DnNBDzK6hw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFP/V/h0YBGUxpvEqNbGfVMWPDB40kATEKdU8cJNyWFIAiBFGLKcaidE6322RYu7B6vShDOHlv99l09/eSjJgeMePQ=="}],"size":181860,"noattachment":false,"key":"/borc/-/borc-2.0.0.tgz"},"maintainers":[{"name":"dignifiedquire","email":"dignifiedquire@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/borc-2.0.0.tgz_1481455315573_0.5183790165465325"},"directories":{},"readme":"# borc\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)\n[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)\n[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)\n[![Coverage Status](https://coveralls.io/repos/github/dignifiedquire/borc/badge.svg?branch=master)](https://coveralls.io/github/dignifiedquire/borc?branch=master)\n[![Dependency Status](https://david-dm.org/dignifiedquire/borc.svg?style=flat-square)](https://david-dm.org/dignifiedquire/borc)\n[![Travis CI](https://travis-ci.org/dignifiedquire/borc.svg?branch=master)](https://travis-ci.org/dignifiedquire/borc)\n\n\n> Assimilate all your JavaScript objects into the Concise Binary Object Representation (CBOR) data format ([RFC7049](http://tools.ietf.org/html/rfc7049)) **as fast as possible**.\n\n\n## About\n\nThis library is a fork of the awesome [node-cbor](https://github.com/hildjj/node-cbor). It borrows a lot of the interface, but drops all streaming and async processing in favor of a minimal syn api and being as fast as possible.\n\n\n## Installation\n\n```bash\n$ npm install --save borc\n```\n\n## Benchmarks\n\nTODO\n\n## Example\n\n```javascript\nconst cbor = require('borc')\nconst assert = require('assert')\n\nconst encoded = cbor.encode(true) // returns <Buffer f5>\nconst decoded = cbor.decodeFirst(encoded)\n// decoded is the unpacked object\nassert.ok(decoded === true)\n\n// Use integers as keys\nvar m = new Map()\nm.set(1, 2)\nencoded = cbor.encode(m) // <Buffer a1 01 02>\n```\n\n## API\n\nSee https://dignifiedquire.github.io/borc for details\n\nThe sync encoding and decoding are exported as a\n[leveldb encoding](https://github.com/Level/levelup#custom_encodings), as\n`cbor.leveldb`.\n\n## Supported types\n\nThe following types are supported for encoding:\n\n* boolean\n* number (including -0, NaN, and ±Infinity)\n* string\n* Array, Set (encoded as Array)\n* Object (including null), Map\n* undefined\n* Buffer\n* Date,\n* RegExp\n* url.URL\n* [bignumber](https://github.com/MikeMcl/bignumber.js)\n\nDecoding supports the above types, including the following CBOR tag numbers:\n\n| Tag | Generated Type |\n|-----|----------------|\n| 0   | Date           |\n| 1   | Date           |\n| 2   | bignumber      |\n| 3   | bignumber      |\n| 4   | bignumber      |\n| 5   | bignumber      |\n| 32  | url.URL        |\n| 35  | RegExp         |\n\n\n## Customizations\n\nBorc supports custom tags as well as custom input types.\n\n### Encode Custom Types\n\n```js\nclass MyType {\n  constructor (val) {\n    this.val = val\n  }\n\n  // Gets called when encoding this object\n  // gen - instance of the encoder\n  // obj - the object being encoded\n  //\n  // should return true on success and false otherwise\n  encodeCBOR (gen) {\n    return gen.pushAny('mytype:' + this.val)\n  }\n}\n\ncbor.encode([new MyType('hello')])\n```\n\n### Encode Custom Tags\n\n```js\ncbor.encode([new cbor.Tagged(42, 'hello')])\n```\n\n### Decode Custom Tags\n\n```js\nconst decoder = new cbor.Decoder({\n  tags: {\n    42: (val) => val + ' world'\n  }\n})\n```\n\n## License\n\nMIT\n","publish_time":1481455318011,"_cnpm_publish_time":1481455318011,"dist-tags":{"latest":"3.0.0"}}