{"_id":"pbs","_rev":"11-452733e8a6b4fbb8c78490bca33895c4","name":"pbs","description":"Streaming encoder/decoder for protocol buffers","dist-tags":{"latest":"1.3.2"},"versions":{"1.0.0":{"name":"pbs","version":"1.0.0","description":"Streaming protocol buffers encoder/decoder","main":"index.js","dependencies":{"generate-function":"^2.0.0","protocol-buffers":"^2.7.0","readable-stream":"^1.0.33","varint":"^4.0.0"},"devDependencies":{"standard":"^3.7.0"},"scripts":{"test":"standard"},"repository":{"type":"git","url":"https://github.com/mafintosh/pbs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/pbs/issues"},"homepage":"https://github.com/mafintosh/pbs","gitHead":"1f080fdba29d41a84b2a6082fb7790f6adf875ca","_id":"pbs@1.0.0","_shasum":"2aac2669f534975721337ae3230f8bb07f65acdf","_from":".","_npmVersion":"2.7.5","_nodeVersion":"1.6.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"dist":{"shasum":"2aac2669f534975721337ae3230f8bb07f65acdf","tarball":"https://registry.npmjs.org/pbs/-/pbs-1.0.0.tgz","integrity":"sha512-rPFllTV6DPJ0yM84GJHCt0bRnEjTsl3jX1UInQYCYm/yXkVNvAQOOeca/cHuFXtg8Kqw6MraF2QPvQFVGIsWvQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDegxkCLF+HCXYVNUe2oj5hKojdSzLJvKC2Vt/o+V21+wIgIsS6npqu/jMnOMEjz/yc2+UnZEQb5WIWwtEFlWrBwzY="}]}},"1.1.0":{"name":"pbs","version":"1.1.0","description":"Streaming protocol buffers encoder/decoder","main":"index.js","dependencies":{"generate-function":"^2.0.0","protocol-buffers":"^2.7.0","readable-stream":"^1.0.33","varint":"^4.0.0"},"devDependencies":{"concat-stream":"^1.4.8","standard":"^3.7.0","tape":"^4.0.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/pbs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/pbs/issues"},"homepage":"https://github.com/mafintosh/pbs","gitHead":"75ba2f539153e439fc8ea4d0f947902e39940034","_id":"pbs@1.1.0","_shasum":"aa6c955fb57c5efb8836dbd14ed578ceca7a9aae","_from":".","_npmVersion":"2.7.5","_nodeVersion":"1.6.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"dist":{"shasum":"aa6c955fb57c5efb8836dbd14ed578ceca7a9aae","tarball":"https://registry.npmjs.org/pbs/-/pbs-1.1.0.tgz","integrity":"sha512-cmlhGaOES5XRtK9rBW9ccju5jdyOu7PGm44mULiYCnoRa+/jmIZ0J1JUJ+VfkmpMg1RXSNColulayNXB4zY/dw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCqyBcL+dK7dnWFAtNxB+G3p0uAdawLX4GX9X1kvfoK5QIhANtDS+Z0pfnndtc/3kgo1RKRc1vOuKkLQX2sX2FThtcA"}]}},"1.2.0":{"name":"pbs","version":"1.2.0","description":"Streaming protocol buffers encoder/decoder","main":"index.js","dependencies":{"generate-function":"^2.0.0","protocol-buffers":"^2.7.0","readable-stream":"^1.0.33","varint":"^4.0.0"},"devDependencies":{"concat-stream":"^1.4.8","standard":"^3.7.0","tape":"^4.0.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/pbs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/pbs/issues"},"homepage":"https://github.com/mafintosh/pbs","gitHead":"02425da57a5ddf9e78702c813d86bf0d5d58770e","_id":"pbs@1.2.0","_shasum":"985f23462a79c697cefd256dbe42d8e7891e045c","_from":".","_npmVersion":"2.7.5","_nodeVersion":"1.6.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"dist":{"shasum":"985f23462a79c697cefd256dbe42d8e7891e045c","tarball":"https://registry.npmjs.org/pbs/-/pbs-1.2.0.tgz","integrity":"sha512-Co7F2Gn6aIVMQKUTN/b68DgnimRmeXNDdK6Bi9JPIr7QyStua5K24RXQtv+cvs9iYrDFrPDArPngCs3KWj5Cow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDmUJfut/AtnsrZUeQVJRIsczL2p6b0Ee6Y6FTMpnDY/wIhANCxLi5LLWkHJ+ikkc5qoeYETmRyUzkt2PswJ47KdZGz"}]}},"1.3.0":{"name":"pbs","version":"1.3.0","description":"Streaming protocol buffers encoder/decoder","main":"index.js","dependencies":{"generate-function":"^2.0.0","protocol-buffers":"^3.0.0","readable-stream":"^1.0.33","varint":"^4.0.0"},"devDependencies":{"concat-stream":"^1.4.8","standard":"^3.7.0","tape":"^4.0.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/pbs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/pbs/issues"},"homepage":"https://github.com/mafintosh/pbs","gitHead":"be58ccb8d2ad4065fc4cb1db18abcde2613ecf89","_id":"pbs@1.3.0","_shasum":"97452e65a696a3919cc7df259d89c3176fed964f","_from":".","_npmVersion":"2.7.5","_nodeVersion":"1.6.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"maxogden","email":"max@maxogden.com"}],"dist":{"shasum":"97452e65a696a3919cc7df259d89c3176fed964f","tarball":"https://registry.npmjs.org/pbs/-/pbs-1.3.0.tgz","integrity":"sha512-9Vw1MeTSKYKSyE3wc5buFwdA6Dw3ch1SyAcGXmog3oubAnMzSp+e1TrcKieLlweifk1bUW/yHfYCq3BfnmHjGg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGwtbNw3lsy8TswoqFVf7hTbQ6R0SdL5PvoCs2u1M9aBAiBqaIUgLmNLrEAYkuGyEBC5gjjpQFpHlTfhWg+Cpb4f7g=="}]}},"1.3.1":{"name":"pbs","version":"1.3.1","description":"Streaming encoder/decoder for protocol buffers","main":"index.js","dependencies":{"generate-function":"^2.0.0","protocol-buffers":"^3.0.0","readable-stream":"^1.0.33","varint":"^4.0.0"},"devDependencies":{"concat-stream":"^1.4.8","standard":"^3.7.0","tape":"^4.0.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/pbs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/pbs/issues"},"homepage":"https://github.com/mafintosh/pbs","gitHead":"c807c6acc52d3de2ed6afe828bcc9c86b8dd9c5c","_id":"pbs@1.3.1","_shasum":"aee7ba4ecf047df8c83e686b86c0fb2cdeb44a08","_from":".","_npmVersion":"2.8.4","_nodeVersion":"1.8.1","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"maxogden","email":"max@maxogden.com"}],"dist":{"shasum":"aee7ba4ecf047df8c83e686b86c0fb2cdeb44a08","tarball":"https://registry.npmjs.org/pbs/-/pbs-1.3.1.tgz","integrity":"sha512-U2JeyIQcVbtuJJP9tnB+JDZYlbjU/Ask9c+HbnYXmJHVOV9bbGXKIAOOudwt6FJkNLmtZYeAf0+trztr0cxP1A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDGRLKkts+nyGCKYwgvmgW07l1YXvyepUZaKi596/zvfAiEA9axvkrbLS2mf4kakhYRfwaHgKbGP44MkaJC1PFRREnI="}]}},"1.3.2":{"name":"pbs","version":"1.3.2","description":"Streaming encoder/decoder for protocol buffers","main":"index.js","dependencies":{"generate-function":"^2.0.0","protocol-buffers":"^3.0.0","readable-stream":"^1.0.33","varint":"^4.0.0"},"devDependencies":{"concat-stream":"^1.4.8","standard":"^3.7.0","tape":"^4.0.0"},"scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mafintosh/pbs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/pbs/issues"},"homepage":"https://github.com/mafintosh/pbs","gitHead":"163e2390e01bf81b83f3fda0ca2823d7eea96e2b","_id":"pbs@1.3.2","_shasum":"cf54fe25b733194aa9268f207232c895141ef12f","_from":".","_npmVersion":"2.9.0","_nodeVersion":"2.0.1","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"maxogden","email":"max@maxogden.com"}],"dist":{"shasum":"cf54fe25b733194aa9268f207232c895141ef12f","tarball":"https://registry.npmjs.org/pbs/-/pbs-1.3.2.tgz","integrity":"sha512-NqD+X56HE8CFElImffpzSflUn2EPaRtzdAeJAZcndy0g9BnAI9LkmIP2TdVECy9GVs9llSHhzdcB7pCA4+uphQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDKUblqjwT36R5D+nWNVoDGQuCcFkmvqybvc5m2w9DhQwIhAO2Ian+q1CauwFir56FNfB877Jm8Z5RQE1hXumZ3wCcG"}]}}},"readme":"# pbs\n\nStreaming encoder/decoder for [protocol buffers](https://developers.google.com/protocol-buffers/)\n\n```\nnpm install pbs\n```\n\n[![build status](http://img.shields.io/travis/mafintosh/pbs.svg?style=flat)](http://travis-ci.org/mafintosh/pbs)\n\n## Usage\n\n``` js\nvar pbs = require('pbs')\n\nvar messages = pbs(`\n  message Company {\n    required string name = 1;\n    repeated Employee employees = 2;\n    optional string country = 3;\n\n    message Employee {\n      required string name = 1;\n      required uint32 age = 2;\n    }\n  }\n`)\n\n// create a streaming encoder\nvar encoder = messages.Company.encode()\n\n// create a streaming decoder\nvar decoder = messages.Company.decode()\n```\n\n## Encoding\n\nUse pbs to encode a protocol buffers message (no matter how large!) to a stream.\n\nThe encoder stream will expose all properties of the protobuf message as methods on the\nstream that you can pass the value you want to write to.\n\n``` js\nencoder.someProperty(aValue, [callback])\n```\n\nThe callback is called when the stream has been flushed.\n\nHere is an example using the above protobuf schema:\n\n``` js\n// all the properties of Company are exposed as methods\nvar encoder = messages.Company.encode()\n\n// encoder is a readable stream containing the protobuf message.\n// you can pipe it anywhere!\nencoder.pipe(fs.createWriteStream('my-protobuf-message.pb'))\n\n// write a name to the stream\nencoder.name('my-company')\n\n// write an employee to the stream\nencoder.employees({\n  name: 'mathias',\n  age: 28\n})\n\n// write another one\nencoder.employees({\n  name: 'jane doe',\n  age: 32\n})\n\n// no more data -  will end the readable stream\nencoder.finalize()\n```\n\nThe encoder stream produces a valid protobuf message that can be decoded with any\nother parser that follows the protobuf spec.\n\n## Decoding\n\nSimilar to encoding you can use pbs to decode a protobuf message.\n\nThe decoder stream also exposes the properties as methods, but instead of passing a value\nyou pass a function that is called then that property is found in the stream.\n\n``` js\ndecoder.someProperty(fn)\n```\n\nHere is an example using the above schema:\n\n``` js\n// all the properties of Company are exposes as methods\nvar decoder = messages.Company.decode()\n\ndecoder.name(function (name, cb) {\n  console.log('message has name:', name)\n  cb() // done processing\n})\n\ndecoder.employees(function (employee, cb) {\n  console.log('employee array member:', employee)\n  cb() // done processing\n})\n\ndecoder.country(function (country, cb) {\n  console.log('message has country:', country)\n  cb()\n})\n\ndecoder.on('finish', function () {\n  console.log('(no more data)')\n})\n\nfs.createReadStream('my-protobuf-message.pb').pipe(decoder)\n```\n\n## Use cases\n\nYou can use this to parse large protobuf messages that might not fit in memory.\n\nAnother use case is to use this to implement a streaming binary protocol encoder/decoder.\nLet's say I wanted to implement a chat protocol. I could describe it using the following proto schema:\n\n```proto\nmessage ChatProtocol {\n  repeated Message messages = 1;\n  repeated string online = 2;\n\n  message Message {\n    required string from = 1;\n    required string text = 2;\n  }\n}\n```\n\nand then just use pbs to parse it:\n\n``` js\nvar fs = require('fs')\nvar pbs = require('pbs')\n\nvar messages = pbs(fs.readFileSync('schema.proto'))\nvar decoder = messages.ChatProtocol.decode()\n\n// read messages\n\ndecoder.online(function (username, cb) {\n  console.log(username + ' is online!')\n  cb()\n})\n\ndecoder.messages(function (message, cb) {\n  console.log(message.from + ' says: ' + message.text)\n})\n\n// write messages\n\nvar encoder = messages.ChatProtocol.encode()\n\nencoder.online('mafintosh')\nencoder.messages({\n  from: 'mafintosh',\n  text: 'hello world!'\n})\n\n// setup the pipeline\nencoder.pipe(someTransportStream).pipe(decoder)\n```\n\nSince the entire stream is valid protobuf, you could even save it to a file\nand parse it using another protobuf parser to debug an application.\n\n## License\n\nMIT\n","maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"maxogden","email":"max@maxogden.com"}],"time":{"modified":"2022-06-23T15:59:02.983Z","created":"2015-04-22T19:07:27.360Z","1.0.0":"2015-04-22T19:07:27.360Z","1.1.0":"2015-04-22T21:30:34.611Z","1.2.0":"2015-04-22T21:43:40.093Z","1.3.0":"2015-04-24T02:39:12.915Z","1.3.1":"2015-05-01T19:09:53.269Z","1.3.2":"2015-05-21T06:32:51.291Z"},"homepage":"https://github.com/mafintosh/pbs","repository":{"type":"git","url":"https://github.com/mafintosh/pbs.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"bugs":{"url":"https://github.com/mafintosh/pbs/issues"},"license":"MIT","readmeFilename":"README.md","users":{"groundwater":true,"akiva":true}}