{"name":"abstract-extension","version":"3.0.1","description":"Small abstraction to help build out user defined extension messages in an RPC system","main":"index.js","dependencies":{"codecs":"^2.0.0"},"devDependencies":{"standard":"^14.3.1","tape":"^4.11.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/mafintosh/abstract-extension.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/abstract-extension/issues"},"homepage":"https://github.com/mafintosh/abstract-extension","gitHead":"a4df8a59029e055be611d95bab79b149de90a79e","_id":"abstract-extension@3.0.1","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-5EQdWgjJo81nR6fK8DeyXzxGQRInxfSxYgLFaP81DaUGix3IAfiz6VtzwXqMjp+qXeYnlGPn/vSSlz13SejbrA==","shasum":"5b1961dbf9dc89fab367a861376a7a0a98693413","tarball":"http://registry-npm.ywwl.com/abstract-extension/download/abstract-extension-3.0.1.tgz","fileCount":5,"unpackedSize":8618,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdo14tCRA9TVsSAnZWagAABr4P/Rd+bHByKioYtRIIQcnf\n01Tityj8cwoDQWYW3NyBanSy3kRtNbsgGUZCoAFvMB8U6869BMNuwFfiPKit\niaaVAcj3nOSlhh9DBmO1Gwj4bRNYlfbD4XBn199hbNsR2AOG9hJlXeE7mJ2W\nfQQvvfR+hyBX2lix39EnxAzPQdKTJJ9W7RiOWfG1jUUBaQxs1+anlvmmcL8r\n3dk+2XraIu7EmWEmhn3ZufRuinZIANiiVsEUmX0i3TQ2L/Phz5k7dLSvs2Zb\n5PUvZAgK11vYdpMNgewJm/1Smy9acoGArV+qEq1YSN+uNOEKaHxJ/eLUC/pL\nOBAihnkF/RAGNZ5VjrPcaFL/vf+qRHshx5dCCgxcDlLB+twYrgg4JhDti/5d\nGfO9yVnLpTtmsxyrIjlP36XyacSGHknv3vRkpue6JBIFi4vYV6ZqcJUq49eK\nd/Yre8yNFwNFyEon6MWzpLRZ9RMaPWqBi0cTmcO8d9+Sn4MfxTXfKfpJF1Ao\nilM4YaWv+a17AD73lNYQlvtsyFhay70gWi2YFLQRPZkWY//RZHXdqt59NNlK\n6DIOzPx3ADRpG1+D6dccyVVTaX+omh77A/pPbQJceS5EW/akuMbzGJSvEFN1\nU23jQuK1W6Sna1aL7nlBZJvtG8TTR9MIttJRPM/y3nyQWaPJ7oT/7q7Fcx6l\nPrt9\r\n=hfX+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGy3K/pO0bZAHa/ls7QEC++/HPn22Yuah69VRdzzolRwAiEAivVBLxfjYfEEA774khm2RcWd5BgTjUAJkGXuwW/D/K8="}],"size":3281,"noattachment":false,"key":"/abstract-extension/-/abstract-extension-3.0.1.tgz"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/abstract-extension_3.0.1_1570987564782_0.520353881997593"},"_hasShrinkwrap":false,"readme":"# abstract-extension\n\nSmall abstraction to help build out user defined extension messages in an RPC system.\n\n```\nnpm install abstract-extension\n```\n\nSee [hypercore](https://github.com/mafintosh/hypercore) and [hypercore-protocol](https://github.com/mafintosh/hypercore-protocol)\nfor a full example on how to use this\n\n## API\n\n#### `const AbstractExtension = require('abstract-extension')`\n\nImports the AbstractExtension class. You should extend this and add the functionality you need.\n\n#### `abstractExtension.destroy()`\n\nDetroy an extension instance. Removes the message from the local pairing instance.\n\n#### `abstractExtension.id`\n\nThe local id of the message. Send this over the wire instead of the message name after exchanging the initial message names.\n\n#### `const bool = abstractExtension.remoteSupports()`\n\nTrue if the remote also supports this message. Note that nothing bad will having from sending a message the remote does not support.\n\n#### `const buffer = abstractExtension.encode(message)`\n\nEncode a message to a buffer based on the message encoding.\n\n#### `const local = AbstractExtension.createLocal(handlers)`\n\nCreate a local message pairing instance.\n\nWhenever the messages are updated `local.onextensionupdate()` will be called if provided.\n\n#### `const msg = local.add(name, handlers)`\n\nAdd a new message. `name` should be the string name of a message.\n\n* `handlers.encoding` is an optional encoding for the message payload. Can be either `json`, `utf-8`, `binary` or any abstract encoding.\n* `handlers.onmessage(message, context)` is called when a message has been received and pairing.\n* `handlers.onerror(error, context)` is called when a message fails to decode.\n\n#### `const list = local.names()`\n\nReturns a sorted list of message names. You need to pass this to another remote pairing instance somehow.\n\n#### `const remote = local.remote()`\n\nCall this to setup remote pairing.\n\n#### `remote.update(localNames)`\n\nPass the names of another instance to setup the pairing\n\n#### `remote.onmessage(id, message, [context])`\n\nPair the remote id with the corresponding local message and call the onmessage handler.\nOptionally pass a context object that is simply passed along to the `message.onmessage` function\n\n## License\n\nMIT\n","publish_time":1570987564889,"_cnpm_publish_time":1570987564889,"dist-tags":{"latest":"3.1.1"}}