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

ssb-conn-staging

v1.0.0

Published

Module that manages potential and optional SSB peer connections

Downloads

246

Readme

ssb-conn-staging

Module that manages potential and optional peer connections. For use with the SSB CONN family of modules.

Visual metaphor: a bench with substitute players, idle and not actively in the game, optionally available and waiting for further instructions to join or not.

staging.png

Usage

This module is only used to create an SSB CONN plugin, not used directly by applications. A ConnStaging instance should be available on the CONN plugin, with the following API:

Types

All staging entries are key-value pairs returned as an array, with the following shape:

type StagingEntry = [Address, Data]

// where...
type Address = string;
type Data = {
  key?: string;
  type?: 'bt' | 'lan' | 'internet';
  stagingBirth: number; // timestamp
  stagingUpdated: number; // timestamp
  [misc: string]: any;
}

In other words, it is an array where the first element is the multiserver address for a staged peer, and the second element is an object that has some fields, e.g. key, type, stagingBirth, stagingUpdated, etc.

API

  • connStaging.stage(address, data): register a peer known by its address (string, must conform to the multiserver address convention) as a newly available peer for potential connections, and a data object argument. Returns a boolean indicating whether stage() inserted the peer (true) or just updated it (false)
  • connStaging.unstage(address): remove the potential peer from the staging database, by its address (string, must conform to the multiserver address convention). Returns a boolean indicating whether unstage() succeeded or not (it fails if the entry we are trying to unstage was not staged in the first place)
  • connStaging.get(address): returns the staged data for an existing peer with the given address, or undefined if the address was not staged
  • connStaging.entries(): returns a new Iterator object that gives [address, data] pairs of the peers currently in staging
  • connStaging.liveEntries(): returns a pull-stream that emits an array of entries (like connStaging.entries(), but an array instead of an Iterator) everytime there are updates to the staging.
  • connStaging.listen(): returns a pull stream that notifies of connection events, as an object {type, address} where type is either 'staged' or 'unstaged'
  • connStaging.close(): terminates any used resources and listeners, in preparation to destroy this instance.

License

MIT