{"name":"abstract-extension","version":"3.1.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":"dc0eab15ff053f8fcac83a3686ffd12cde891df9","_id":"abstract-extension@3.1.1","_nodeVersion":"12.17.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-qmUIqQEh6ZZBKN6JfysKgCEBqI4qVexE6/N/MUJjqtQhhuGR8a16GKnK6SGFKv/n1cAlbYxLDXbtyhkxSnVYRQ==","shasum":"2c215ef08197c94b791746792889dfd350c07a8b","tarball":"http://registry-npm.ywwl.com/abstract-extension/download/abstract-extension-3.1.1.tgz","fileCount":5,"unpackedSize":9097,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe5427CRA9TVsSAnZWagAANs8P/3toiOYhzW2h7ngGVXuL\ngzA9CM89/1LFO8q1p5puI5WR4pIlYK52G+n0uvCT05MgQTLfomEltIqiHFpM\nA9+7zG9l2bQU07hx/QtBYuJvDWejdT++nP4iEu+0KLgaqVPQ3CQUjAgDuvkE\nInNK6A7vJ3IgdEOHa+9fUmn9A5xO2Fs5pJbA/3jbVi1BAmHRTcEEIRP84Czu\nwmNJJJMTeWnFHcwcQbFtDE9gVlGEy0toJElXQ69+WdXiTZgJIu6F+AeAYQG+\nfAipKEDck0IOji9ZmumeP7UmJZLVUXZHVNhI91ZuLEXLj8CG5lA8BitOelmK\n63OhLdppkgPKBU166MvAO1SXM3Qe4o6wiD7mg7Kg4UZ639BqCKPjExRF7u1y\nZbJvhdwN2XOD98QY+YjjAXxUpAevrrMzL0KuoxxZuLBLnHcyg8SoB3aYRlGT\nIjo3g2+WbwqpvAR9Aui5vRqB952WW7sbrrbi5fFfDkwDHMqWpg1bF/7ANF2v\nfhSRuPmU/aH5+f6BpmFtRRJzraxuL2XKWttJM+l3y+CXQFbCB8VL2sWl50Hy\n/EXn2difTby2qDQf586frkaS/sLYSQSEYoKsu7zLbLfPr14gXahA9wCwOrXC\n/kUPkKC0iksZT6R2AmUfsaA9/uzBmX/mcx6PlGyTIlmeMgos8wprHbzRANln\nMcCv\r\n=mFSt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMpBcSpVNUcwDnbnvjFa6Bq9cxilub9ypQKhAWnIXGzQIhAJhv930/IfsrbJTEIRloQ8+3hYqQePsqMpe3OcX2sVzW"}],"size":3403,"noattachment":false,"key":"/abstract-extension/-/abstract-extension-3.1.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.1.1_1592233403046_0.6033786273418056"},"_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":1592233403144,"_cnpm_publish_time":1592233403144,"dist-tags":{"latest":"3.1.1"}}