{"name":"abstract-extension","version":"3.0.0","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":"281bcffbe71c645f7ec4252e2c4f06b14f305e0d","_id":"abstract-extension@3.0.0","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-HyYIe53NzOPmvPZ/GUjdbF4B/R9xj+bt0wqd9CLsr3Z8vPHY64WEvjbuxDigKDvzfm0y+ugwyX/n2CvpP9Lnfw==","shasum":"9054726844c177df5edb2a23eabe659073c47dbf","tarball":"http://registry-npm.ywwl.com/abstract-extension/download/abstract-extension-3.0.0.tgz","fileCount":5,"unpackedSize":8608,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdo122CRA9TVsSAnZWagAAcUQQAIHUENHhsiuwo5OXP5BU\nOYYWJlJO8xDuwgMxPOWf4X11+qhQ4RZlFAuF9OgMupSFrQTgOD9zRWJ+PXL8\n67CprcLFjBR0Qs0TsIoV+x3ZQ/gLpgg6JGPIDhbVPigumpleiDf55pHOmFkA\nyK65zu2HEeqKhk2vtumNE+IgBHnEQkbo3rhYC/kyna6ifT7p1FjAubceaFx+\n5Zvig9ioTTCNO4VNtUF/publu7DzoV79SBXLFfclsgNopXrenx/ZSEGioNg3\nCC3aahSZCA2a7PsCrFoZa7z22ceIOSKfQaGLG8NjpeQ0S66DLzkjbtSF2Wqs\ntYdHYIwqJYpqgf5lCdC6Ht2+nhRsZZ/cM3LrOWPtN3nghTv17oeWFpxf8ZMe\n4HK00TgOOc2UJUmgLSlqYvmU/SsghMANW0jz5Y0OPPsAoNFHhD5W2jphN2Zw\ndB+SyOcXUV/cUWSGKJjHqQj1v8WLG2FVrzBlcL5RVFE2jR/ArVVWwJKKz3wf\nr2nXjRgoFJddUVhNhNuMljy7BMzu6OEWRPdFYmHegDuw0dOJvsbFg1xwRGL/\nE2jpFZ/RqWPJpRijeO3b8UN9GZzrx9JUWhbGrDY/z4dHAQbCW7HcaBI8svqt\nuUOGHsGFIjGzYqvsb7mK0tdgVxVsItzEPwFiQP9poofDwQ6MEGasro4mx3pV\nxMIM\r\n=WPvp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAcVzX+NHmnhE2nRNiPP2a4E7+6RCMTtWe/+ooloMoQOAiB3PCduodnvB0iBSrVKT7PxAz/jD6cxF/C8BgzWtg9JBg=="}],"size":3281,"noattachment":false,"key":"/abstract-extension/-/abstract-extension-3.0.0.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.0_1570987445412_0.9344729055192393"},"_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":1570987445509,"_cnpm_publish_time":1570987445509,"dist-tags":{"latest":"3.1.1"}}