{"_id":"simple-message-channels","_rev":"481584","name":"simple-message-channels","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","dist-tags":{"latest":"1.2.1"},"maintainers":[{"name":"mafintosh","email":""}],"time":{"modified":"2021-08-05T09:39:40.000Z","created":"2019-08-09T14:46:58.080Z","1.2.1":"2019-10-09T11:58:54.699Z","1.2.0":"2019-10-09T09:16:37.869Z","1.1.3":"2019-10-08T12:28:19.458Z","1.1.2":"2019-09-06T10:36:02.035Z","1.1.1":"2019-08-29T12:50:19.643Z","1.1.0":"2019-08-29T12:14:43.794Z","1.0.0":"2019-08-09T15:01:11.598Z","0.0.0":"2019-08-09T14:46:58.080Z"},"users":{},"author":{"name":"Mathias Buus","url":"@mafintosh"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"versions":{"1.2.1":{"name":"simple-message-channels","version":"1.2.1","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"tape":"^4.11.0"},"scripts":{"test":"tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","gitHead":"318e0281eb3b491fc1715c69944e2f86e990f797","_id":"simple-message-channels@1.2.1","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"shasum":"d827d3da0df1f862fd09b748457a01f9a0eb7ac3","size":3625,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-1.2.1.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_1.2.1_1570622334533_0.29251376370660886"},"_hasShrinkwrap":false,"publish_time":1570622334699,"_cnpm_publish_time":1570622334699},"1.2.0":{"name":"simple-message-channels","version":"1.2.0","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"tape":"^4.11.0"},"scripts":{"test":"tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","gitHead":"5bcf1e469c7bc6308c0857aad32c3a0d88a98101","_id":"simple-message-channels@1.2.0","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"shasum":"51cf40b0dc730f61823e58dbd8ad37a57e112709","size":3618,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-1.2.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_1.2.0_1570612597707_0.7604325820192193"},"_hasShrinkwrap":false,"publish_time":1570612597869,"_cnpm_publish_time":1570612597869},"1.1.3":{"name":"simple-message-channels","version":"1.1.3","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"tape":"^4.11.0"},"scripts":{"test":"tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","gitHead":"992d35f8601068981faa691bef38a5223e80d642","_id":"simple-message-channels@1.1.3","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"shasum":"ec318586b283ac88ffd94c2fc9327d6b4d079968","size":3489,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-1.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-1.1.3.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_1.1.3_1570537699073_0.7275963837672477"},"_hasShrinkwrap":false,"publish_time":1570537699458,"_cnpm_publish_time":1570537699458},"1.1.2":{"name":"simple-message-channels","version":"1.1.2","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"tape":"^4.11.0"},"scripts":{"test":"tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","gitHead":"8b68dc93a381a7ab1b20194e939136b42d9b303b","_id":"simple-message-channels@1.1.2","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"shasum":"f4e8f5a1bba1aac20621bdc824dff90f70cc32e2","size":3430,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-1.1.2.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_1.1.2_1567766161874_0.4736702199444962"},"_hasShrinkwrap":false,"publish_time":1567766162035,"_cnpm_publish_time":1567766162035},"1.1.1":{"name":"simple-message-channels","version":"1.1.1","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"tape":"^4.11.0"},"scripts":{"test":"tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","gitHead":"86aa23da7397be4de8e0557e68ef3775f4542b7e","_id":"simple-message-channels@1.1.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"shasum":"326a22e87f888f319da05112f5db8f56c651f721","size":3347,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-1.1.1.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_1.1.1_1567083019464_0.9295307217782194"},"_hasShrinkwrap":false,"publish_time":1567083019643,"_cnpm_publish_time":1567083019643},"1.1.0":{"name":"simple-message-channels","version":"1.1.0","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"tape":"^4.11.0"},"scripts":{"test":"tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","gitHead":"bc1321ab62e7236d9244ef84e3885fbcf86427d7","_id":"simple-message-channels@1.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"shasum":"64ebe619dcad4bac5e23674721694dcfb71ff21c","size":3337,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-1.1.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_1.1.0_1567080883667_0.9311013423336287"},"_hasShrinkwrap":false,"publish_time":1567080883794,"_cnpm_publish_time":1567080883794},"1.0.0":{"name":"simple-message-channels","version":"1.0.0","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"standard":"^13.1.0","tape":"^4.11.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","gitHead":"0c18ef0d68ca1ed6fb390e49cdc60d3cda195a24","_id":"simple-message-channels@1.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"shasum":"39c48539917516fb167cd4d2b356a650bc3fae31","size":3166,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-1.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_1.0.0_1565362871499_0.9292088499945186"},"_hasShrinkwrap":false,"publish_time":1565362871598,"_cnpm_publish_time":1565362871598},"0.0.0":{"name":"simple-message-channels","version":"0.0.0","description":"Simple streamable state machine that implements a useful channel, message-type, message pattern","main":"index.js","dependencies":{"varint":"^5.0.0"},"devDependencies":{"standard":"^13.1.0"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/simple-message-channels.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"homepage":"https://github.com/mafintosh/simple-message-channels","_id":"simple-message-channels@0.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"shasum":"db1eaa1202b105ceefec5224887438b960426417","size":2741,"noattachment":false,"key":"/simple-message-channels/-/simple-message-channels-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/simple-message-channels/download/simple-message-channels-0.0.0.tgz"},"maintainers":[{"name":"mafintosh","email":""}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-message-channels_0.0.0_1565362017902_0.2613699501357276"},"_hasShrinkwrap":false,"publish_time":1565362018080,"_cnpm_publish_time":1565362018080}},"readme":"# simple-message-channels\n\nSimple streamable state machine that implements a useful channel, message-type, message pattern\n\n```\nnpm install simple-message-channels\n```\n\n[![Build Status](https://travis-ci.org/mafintosh/simple-message-channels.svg?branch=master)](https://travis-ci.org/mafintosh/simple-message-channels)\n\n## Usage\n\n``` js\nconst SMC = require('simple-message-channels')\n\nconst a = new SMC({\n  onmessage (channel, type, message) {\n    console.log('Received a message on channel', channel) // a number\n    console.log('Message type is', type) // a number\n    console.log('And the message payload was', message) // a buffer\n  }\n})\n\nconst b = new SMC()\n\n// produce a payload\nconst payload = b.send(0, 1, Buffer.from('hi'))\n\n// somehow send it to the other instance (over a stream etc)\n// can arrive chunked as long as it arrives in order\na.recv(payload)\n```\n\n(This is the basic wire protocol used by hypercore, https://github.com/mafintosh/hypercore)\n\n## API\n\n#### `payloadBuffer = smc.send(channel, type, message)`\n\nEncode a channel, type, message to be sent to another person.\nChannel can be any number and type can be any 4 bit number.\nMessage should be a buffer.\n\n#### `success = smc.recv(payloadChunk)`\n\nParse a payload buffer chunk. Once a full message has been parsed\nthe `smc.onmessage(channel, type, message)` handler is called.\n\nReturns true if the chunk seemed valid and false if not.\nIf false is returned check `smc.error` to see the error it hit.\n\n#### `payloadBuffer = smc.sendBatch([{ channel, type, message }, ...])`\n\nEncodes a series of messages into a single paylaod buffer.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/mafintosh/simple-message-channels","bugs":{"url":"https://github.com/mafintosh/simple-message-channels/issues"},"license":"MIT"}