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

hyperplexer

v0.9.0

Published

🐙 hypercore multiplexer and replication manager

Downloads

13

Readme

Build Status JavaScript Style Guide standard-readme compliant

hyperplexer

hypercore multiplexer and replication manager 🐙

Version: 0.9

hyperplexer provides you with a general purpose RPC as opposed to implementing your own hypercore-protocol-extension.

  • lower level api exposed through 4 callbacks
  • Custom data exchange similar to http-headers
  • Replicates multiple feeds per Peer connection
  • Keeps track of which feeds your neighbours have or miss

TODO:

  • [x] feed-filters
  • [ ] 🔥feed hot-swapping (in progress) epic
  • [ ] compress peer#feeds LUTs into routing filters
  • [ ] cache exchanged feedDescriptors and headers

NICE TO HAVE:

  • [x] Acts as hypercore-protocol-extension host (accepts other extensions)
  • [ ] Make ext-host impl uniform using abstract-extension

Install

yarn add hyperplexer
# or
npm install hyperplexer

Run interactive hypersim session with:

$(npm bin)/hypersim -T scenarios/multi-index-swarm.js

Usage

const Hyperplexer = require('hyperplexer')
const rpcChannelKey = require('crypto').randomBytes(32)

const mux = new Hyperplexer(rpcChannelKey, {
  onerror: err => console.error(err),

  // Invoked when a new PeerConnection is added to the manager.
  onconnect: peer => {
    const feeds = // get list of feeds from a core store

    const descriptors = feeds.map(feed => {
      // A descriptor must contain prop `key`
      // and optionally custom headers
      return {
        key: feed.key,
        headers: { // Attach anything you want
          length: feed.length,
          color: feed.get(0),
          interesting: Math.random() > 0.5 ? true : false
        }
      }
    })

    mux.share(peer, descriptors)
  },

  // Invoked when our we receive a manifest/ Once for each descriptor
  onaccept: (feedDescriptor, accept) => {
    const { key, headers, peer } = feedDescriptor
    if (headers.interesting === true) {
      accept(true) // includes `key` in next replicationRequest signal.
    } else {
      accept(false) // passively signals "do not want"
    }
  }

  // Resolve key to feed
  onresolve: (resolveReq, resolve) => {
    const { key } = resolveReq
    const feed = // Look up or create feed by key in a core store
    resolve(feed)
  },

  // Invoked with a list of `peers` that are unaware of `key`
  // usually happens when a new user joins the swarm, this handler
  // lets you announce their presence to the rest of the network.
  onforward: (namespace, key, peers) { // see #share() for info on namespaces
    const descriptors = // same as in `onconnect`

    peers.forEach(peer => {
      mux.share(peer, descriptors)
    })
  }
})

// With hyperswarm
hyperswarm.join(Buffer.from('Topic with hyperplexing peers'))

hyperswarm.on('connect', (socket, details) => {
 const peerConn = mux.handleConnection(!!details.client, socket)
})

See JSdoc annotations in index.js for more info on the handlers and opts objects.

Contributing

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

Ad

 _____                      _   _           _
|  __ \   Help Wanted!     | | | |         | |
| |  | | ___  ___ ___ _ __ | |_| |     __ _| |__  ___   ___  ___
| |  | |/ _ \/ __/ _ \ '_ \| __| |    / _` | '_ \/ __| / __|/ _ \
| |__| |  __/ (_|  __/ | | | |_| |___| (_| | |_) \__ \_\__ \  __/
|_____/ \___|\___\___|_| |_|\__|______\__,_|_.__/|___(_)___/\___|

If you're reading this it means that the docs are missing or in a bad state.

Writing and maintaining friendly and useful documentation takes
effort and time. In order to do faster releases
I will from now on provide documentation relational to project activity.

  __How_to_Help____________________________________.
 |                                                 |
 |  - Open an issue if you have ANY questions! :)  |
 |  - Star this repo if you found it interesting   |
 |  - Fork off & help document <3                  |
 |.________________________________________________|

I publish all of my work as Libre software and will continue to do so,
drop me a penny at Patreon to help fund experiments like these

Patreon: https://www.patreon.com/decentlabs
Discord: https://discord.gg/K5XjmZx
Telegram: https://t.me/decentlabs_se

License

GNU AGPLv3 © Tony Ivanov