npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hyper-flood

v1.1.0

Published

Flooding broadcast using hypercore-protocol extensions

Downloads

6

Readme

hyper-flood

Flooding broadcast using hypercore-protocol extensions

npm i --save hyper-flood
const HyperFlood = require('hyper-flood')

const feed = hypercore()

const flood = new HyperFlood()

feed.registerExtension('example', flood.extension())

flood.on('message', (message) => console.log(message.toString('utf8')))

feed.on('peer-open', () => {
	flood.broadcast(Buffer.from('Hello World!'))
})

How it works

This uses hypercore-protocol extension messages to broadcast messages throughout a network using flooding. Each message gets tagged with a unique ID and peers will pass on any messages they see, and ignore messages they've already seen. There's also a TTL (defaults to 255) if you want to limit how far it travlls. Interally, there's an LRU that remembers the l

API

const flood = new HyperFlood({id, lruSize, ttl, messageNumber})

Creates a new instance of a flood. All configs are optional

  • id is a Buffer with some sort of unique identifier. This gets randomly generated if not provided.
  • lruSize is how many message IDs should be remembered at a time to avoid duplicates. Defaults to 255
  • ttl is the number of hops a message can travel before it'll get ignored, defaults to 255
  • messageNumber is the message index to start with. Defaults to 0. Not sure why you'd set this.

flood.on('message', (message, originId, messageNumber) => whatever)

You can listen on messages that show up through the flood with this event.

  • message is a Buffer for the message that got sent.
  • originId is the id of the peer this message originated from (no guarantee it's them)
  • messageNumber is the message index for this message from this peer.

flood.on('error', (err) => whatever)

This gets emitted when there's an error, usually while parsing the message data.

flood.broadcast(message, ttl)

Use this to broadcast out messages into the network.

  • message should be a Buffer to send out to the swarm.
  • ttl is optional and will use the TTL specified in the constructor by default.

const extensionHandlers = flood.extension()

This will create extension handlers for use in hypercore-protocol.

  • extensionHandlers should be passed to protocol.registerExtension or feed.registerExtension.

Credits

Ce logiciel a été créé dans le cadre du projet de plateforme virtuelle de création autochtone P2P Natakanu. Une réalisation de Wapikoni Mobile, Uhu Labos Nomades et du Bureau de l'engagement communautaire de l'université Concordia. Projet financé dans le cadre de l'Entente sur le développement culturel de Montréal conclue entre la Ville de Montréal et gouvernement du Québec.


This software was created as part of Natakanu, a P2P indigenous platform produced by Wapikoni Mobile, Uhu Labos Nomades and the Office of Community Engagement at Concordia University. Project funded under the Montreal cultural development agreement between the city of Montreal and the government of Quebec.