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

paravel

v0.5.7

Published

Yet another toolkit for nostr

Downloads

166

Readme

Paravel version

A nostr toolkit focused on creating highly a configurable client system. What paravel provides is less a library of code than a library of abstractions. Odds are you will end up creating a custom implementation of every component to suit your needs, but if you start with paravel that will be much easier than if you pile on parameters over time.

/util

Some general-purpose utilities used in paravel.

  • Deferred is just a promise with resolve and reject methods.
  • Emitter extends EventEmitter to support emitter.on('*', ...).
  • Fluent is a wrapper around arrays with chained methods that modify and copy the underlying array.
  • Kinds contains kind constants and related utility functions.
  • LRUCache is an implementation of an LRU cache.
  • Queue is an implementation of an asynchronous queue.
  • Relays contains utilities related to relays.
  • Router is a utility for selecting relay urls based on user preferences and protocol hints.
  • Tags and Tag extend Fluent to provide a convenient way to access and modify tags.
  • Tools is a collection of general-purpose utility functions.

/connect

Utilities having to do with connection management and nostr messages.

  • ConnectionMeta tracks stats for a given Connection.
  • Connection is a wrapper for Socket with send and receive queues, and a ConnectionMeta instance.
  • Executor implements common nostr flows on target
  • Pool is a thin wrapper around Map for use with Relays.
  • Socket is a wrapper around isomorphic-ws that handles json parsing/serialization.
  • Subscription is a higher-level utility for making requests against multiple nostr relays.

/connect/target

Executor targets extend Emitter, and have a send method, a cleanup method, and a connections getter. They are intended to be passed to an Executor for use.

  • Multi allows you to compose multiple targets together.
  • Plex takes an array of urls and a Connection and sends and receives wrapped nostr messages over that connection.
  • Relay takes a Connection and provides listeners for different verbs.
  • Relays takes an array of Connections and provides listeners for different verbs, merging all events into a single stream.

Example

Functionality is split into small chunks to allow for changing out implementations as needed. This is useful when attempting to support novel use cases. Here's a simple implementation of an agent that can use a multiplexer if enabled, or can fall back to communicating directly with all relays.

class Agent {
  pool = new Pool()

  constructor(readonly multiplexerUrl: string) {}

  getTarget(urls) {
    return this.multiplexerUrl
      ? new Plex(urls, this.pool.get(this.multiplexerUrl))
      : new Relays(urls.map(url => this.pool.get(url)))
  }

  subscribe(urls, filters, id, {onEvent, onEose}) {
    const executor = new Executor(this.getTarget(urls))

    return executor.subscribe(filters, id, {onEvent, onEose})
  }
}