{"name":"codecs","version":"1.0.0","description":"Create an binary encoder/decoder for json, utf-8 or custom types","main":"index.js","dependencies":{},"devDependencies":{"standard":"^8.5.0","tape":"^4.6.3"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/codecs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/codecs/issues"},"homepage":"https://github.com/mafintosh/codecs","gitHead":"95af36ea0198771ae9d1f9f3e92575b0da503f1c","_id":"codecs@1.0.0","_shasum":"3c7282b746aa8f21f901270569322f737e71b537","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"3c7282b746aa8f21f901270569322f737e71b537","tarball":"http://registry-npm.ywwl.com/codecs/download/codecs-1.0.0.tgz","integrity":"sha512-saV912jUHYcL4dMIv5TUIlJQikr1kfsxV0Lj93fO33FC/7kS+/SkzVLxzl/yf+p+735mWjmYDo2eMMgMT/Af/w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFEBK55foL8nB211r+UyrBxQjc6jBTi2m0CMqePdmQbrAiBsbxdwBJyfH3bVWPdFHT+vTvh97ZISUtDhHlQvMPc2AQ=="}],"size":2130,"noattachment":false,"key":"/codecs/-/codecs-1.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/codecs-1.0.0.tgz_1479853238275_0.267765881260857"},"directories":{},"readme":"# codecs\n\nCreate an binary encoder/decoder for Node's build in types like, json, utf-8, hex.\n\n```\nnpm install codecs\n```\n\nUseful to support value encodings similar to leveldb's.\n\n## Usage\n\n``` js\nconst codecs = require('codecs')\nconst json = codecs('json')\n\nconsole.log(json.encode({ hello: 'world' })) // Buffer.from('{\"hello\":\"world\"}')\nconsole.log(json.decode(new Buffer('{\"hello\":\"world\"}'))) // { hello: 'world' }\n```\n\n## API\n\n#### `const codec = codecs(type, [fallback])`\n\nCreate a new codec.\n\nSupported types are\n\n* utf8\n* json\n* [ndjson](http://ndjson.org/)\n* binary\n* hex\n* ascii\n* base64\n* ucs2\n* ucs-2\n* utf16le\n* utf-16le\n* binary\n\nIf an unknown type is passed-in, the `fallback` is used if given, else `binary`.\nIf you want to use a custom codec you can pass in an object containing a an `encode` and `decode` method and that will be returned.\nIf you pass a [compact encoder](https://github.com/compact-encoding/compact-encoding), then it will be converted into a codec for you and returned.\n\n#### `const buf = codec.encode(value)`\n\nEncode a value to a buffer.\n\n#### `const value = codec.decode(buf)`\n\nDecode a buffer to a value.\n\n## License\n\nMIT\n","publish_time":1479853240208,"_cnpm_publish_time":1479853240208,"dist-tags":{"latest":"3.1.0"}}