{"_id":"protocol-buffers-encodings","_rev":"4577431","name":"protocol-buffers-encodings","description":"Base encodings for protocol-buffers","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"mafintosh","email":""}],"time":{"modified":"2026-04-10T15:47:29.000Z","created":"2018-01-17T13:45:01.251Z","1.2.0":"2022-08-02T17:56:08.903Z","1.1.1":"2020-09-28T14:25:18.439Z","1.1.0":"2018-01-17T13:53:19.184Z","1.0.0":"2018-01-17T13:45:01.251Z"},"users":{},"author":{"name":"Mathias Buus","url":"@mafintosh"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/protocol-buffers-encodings.git"},"versions":{"1.2.0":{"name":"protocol-buffers-encodings","version":"1.2.0","description":"Base encodings for protocol-buffers","main":"index.js","dependencies":{"b4a":"^1.6.0","signed-varint":"^2.0.1","varint":"5.0.0"},"devDependencies":{"standard":"^14.3.4","tape":"^5.0.1"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/protocol-buffers-encodings.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/protocol-buffers-encodings/issues"},"homepage":"https://github.com/mafintosh/protocol-buffers-encodings","gitHead":"59bc47d9c5cae4bda1dcb5db92c30f56bbe65d70","_id":"protocol-buffers-encodings@1.2.0","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"shasum":"39900b85dcff3172a23f15bdf3fda70daa2b38d3","size":3994,"noattachment":false,"key":"/protocol-buffers-encodings/-/protocol-buffers-encodings-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/protocol-buffers-encodings/download/protocol-buffers-encodings-1.2.0.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protocol-buffers-encodings_1.2.0_1659462968697_0.5356515523497922"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-08-02T18:01:13.288Z","publish_time":1659462968903,"_cnpm_publish_time":1659462968903},"1.1.1":{"name":"protocol-buffers-encodings","version":"1.1.1","description":"Base encodings for protocol-buffers","main":"index.js","dependencies":{"signed-varint":"^2.0.1","varint":"5.0.0"},"devDependencies":{"standard":"^14.3.4","tape":"^5.0.1"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/protocol-buffers-encodings.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/protocol-buffers-encodings/issues"},"homepage":"https://github.com/mafintosh/protocol-buffers-encodings","gitHead":"d5cc37b7477c5092b8b4c4da837b8e38b4949108","_id":"protocol-buffers-encodings@1.1.1","_nodeVersion":"14.10.1","_npmVersion":"6.14.8","dist":{"shasum":"f1e4a386711823137330171d2c82b49d062e75d3","size":3633,"noattachment":false,"key":"/protocol-buffers-encodings/-/protocol-buffers-encodings-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/protocol-buffers-encodings/download/protocol-buffers-encodings-1.1.1.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protocol-buffers-encodings_1.1.1_1601303118327_0.09241571471301246"},"_hasShrinkwrap":false,"publish_time":1601303118439,"_cnpm_publish_time":1601303118439},"1.1.0":{"name":"protocol-buffers-encodings","version":"1.1.0","description":"Base encodings for protocol-buffers","main":"index.js","dependencies":{"signed-varint":"^2.0.1","varint":"^5.0.0"},"devDependencies":{"standard":"^10.0.3","tape":"^4.8.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/protocol-buffers-encodings.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/protocol-buffers-encodings/issues"},"homepage":"https://github.com/mafintosh/protocol-buffers-encodings","gitHead":"7768744fec6c452de27ed1f9212bf526d443d4ad","_id":"protocol-buffers-encodings@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"f3905631106669b85381bad47a336add7d206873","size":3670,"noattachment":false,"key":"/protocol-buffers-encodings/-/protocol-buffers-encodings-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/protocol-buffers-encodings/download/protocol-buffers-encodings-1.1.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protocol-buffers-encodings-1.1.0.tgz_1516197198069_0.15216099540703"},"directories":{},"publish_time":1516197199184,"_hasShrinkwrap":false,"_cnpm_publish_time":1516197199184},"1.0.0":{"name":"protocol-buffers-encodings","version":"1.0.0","description":"Base encodings for protocol-buffers","main":"index.js","dependencies":{"signed-varint":"^2.0.1","varint":"^5.0.0"},"devDependencies":{"standard":"^10.0.3","tape":"^4.8.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/protocol-buffers-encodings.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/protocol-buffers-encodings/issues"},"homepage":"https://github.com/mafintosh/protocol-buffers-encodings","gitHead":"cb915adebecd857bfe6a295841c33e00be8e134c","_id":"protocol-buffers-encodings@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"dist":{"shasum":"46483d698e77afb5c7ec8fb59503d48ed5f6e83c","size":3512,"noattachment":false,"key":"/protocol-buffers-encodings/-/protocol-buffers-encodings-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/protocol-buffers-encodings/download/protocol-buffers-encodings-1.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protocol-buffers-encodings-1.0.0.tgz_1516196700071_0.665986459236592"},"directories":{},"publish_time":1516196701251,"_hasShrinkwrap":false,"_cnpm_publish_time":1516196701251}},"readme":"# protocol-buffers-encodings\n\nBase encodings for [protocol-buffers](https://github.com/mafintosh/protocol-buffers).\n\n```\nnpm install protocol-buffers-encodings\n```\n\nNote: use Node.js >= 16.15.0 to avoid a performance regression due to a slower `Buffer.subarray` function.\n\n[![build status](https://travis-ci.org/mafintosh/protocol-buffers-encodings.svg?branch=master)](https://travis-ci.org/mafintosh/protocol-buffers-encodings)\n\nMoved into its own module for lighter installs\n\n## Usage\n\n``` js\nvar encodings = require('protocol-buffers-encodings')\nvar buf = Buffer.alloc(4096)\n\nencodings.string('hi', buf, 0)\nconsole.log(encodings.string(buf, 0)) // prints 'hi'\n```\n\n## API\n\nIn general all encoders follow this API\n\n#### `buffer = enc.encode(value, buffer, offset)`\n\nEncode a value. `buffer` should be a buffer big enough to fit the value, `offset` should be the byte offset in the buffer where you want to write it.\nThe buffer is returned for convenience.\n\nAfter a value has been encoded `enc.encode.bytes` contains the amount of bytes used in the buffer.\n\n#### `value = enc.decode(buffer, offset)`\n\nDecode a value. `buffer` should be an encoded value and `offset` should be the byte offset where you want to start decoding.\n\nAfter a value has been decoded `enc.decode.bytes` contains the amount of bytes that was consumed from the buffer.\n\n#### `var len = enc.encodingLength(value)`\n\nUse this method to calculate how much space is needed to encode a value.\n\n#### `enc.type`\n\nA number indicating the protobuf wire type for the encoding\n\n## Encodings\n\nThe following encodings are available\n\n* `encodings.bytes` - encode a buffer\n* `encodings.string` - encode a string\n* `encodings.bool` - encode a boolean\n* `encodings.uint64` - encode a uint64 to varint\n* `encodings.uint32` - encode a uint32 to varint\n* `encodings.sint64` - encode a signed int64 to a signed varint\n* `encodings.sint32` - encode a signed int32 to a signed varint\n* `encodings.int64` - encode a signed int64 to a varint\n* `encodings.int32` - encode a signed int32 to a varint\n* `encodings.fixed32` - encode a uint32 to a fixed 4 byte buffer\n* `encodings.sfixed32` - encode a signed int32 to a fixed 4 byte buffer\n* `encodings.fixed64` - encode a uint64 (represented as a buffer) to a fixed 8 byte buffer\n* `encodings.sfixed64` - encode a signed int64 (represented as a buffer) to a fixed 8 byte buffer\n* `encodings.double` - encode a double\n* `encodings.float` - encode a float\n* `encodings.enum` - encode a numeric enum as a varint\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/mafintosh/protocol-buffers-encodings","bugs":{"url":"https://github.com/mafintosh/protocol-buffers-encodings/issues"},"license":"MIT"}