@geut/network-setup

3.0.1 • Public • Published

network-setup

Create network simulations to test your peers and connections using ngraph

Test Status JavaScript Style Guide standard-readme compliant

Made by GEUT

Install

$ npm install @geut/network-setup

Usage

const { NetworkSetup, Peer, Connection } = require('@geut/network-setup')

// defines the generator
const setup = new NetworkSetup({
  onPeer(node) {
    // Creates a peer
    return new Peer(node, {
      // open/close are hooks to execute operations inside of peer lifecycle
      async open() {},
      async close() {}
    })
  },
  onConnection(link, fromPeer, toPeer) {
    return new Connection(link, {
      // open/close are hooks to execute operations inside of connection lifecycle
      async open() {},
      async close() {}
    })
  }
})

;(async () => {
  // Create a balanced binary tree with 3 levels
  const network = await setup.balancedBinTree(3)
})()

Issues

🐛 If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.

Contributing

👥 Ideas and contributions to the project are welcome. You must follow this guideline.

License

MIT © A GEUT project

Dependents (0)

Package Sidebar

Install

npm i @geut/network-setup

Weekly Downloads

0

Version

3.0.1

License

MIT

Unpacked Size

18.2 kB

Total Files

8

Last publish

Collaborators

  • geutuser
  • the-real-dk
  • tinchoz49
  • estebanprimost