Socket
Socket
Sign inDemoInstall

hmq

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmq

Hypercore based queue module


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Hmq

Hmq is a Hyperbee based rpc. A node using hmq can be controller by adding one or more Hyperbee controllers.

Example

Controlled node

const { Hmq } = require('hmq')
const ram = require('random-access-memory')
const controller = process.argv[2].split(',')

const callback = (data) => {
 if(data.key === "say-hi"){
   console.log(data.controller, "says hi!")
 }
}

const rpc = new Hmq(ram, {callback : callback})
await rpc.init()
await rpc.add(controller)

Controller

const { HmqController } = require('hmq')

const controller = new HmqController()
await controller.init()
console.log(controller.core.key.toString('hex'))
setInterval(async () => await controller.send('say-hi'), 2000)

API

const hmq = new Hmq(storage, opts = {})
  • storage: corestore storage
  • opts.core: hypercore public key of controllers Hyperbee. Can use this to replicate a controlled node.
  • opts.callback: function with signature (key, value, seq) => result. This is the callback function for every new entry in any controller. Result will be store in another Hyperbee with key controller.key!key!value!seq.

hmq.init()

Setup controllers and start watching.

hmq.add(key)

Add new controller by Hypercore public key.

hmq.on('update', entry)

Event emmited when new controller entry found.

hmq.on('controller', key)

Event emmited when new controller added.

FAQs

Package last updated on 21 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc