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

rx-nostr

v3.4.0

Published

A library based on RxJS, which allows Nostr applications to easily communicate with relays.

Downloads

1,146

Readme

Description

rx-nostr provides transparent interface to read/write events on Nostr relays. You can exchange data in a very familiar way (as you see NIP-01) with that interface, but it allows for far more robust and flexible communication than you can do by touching WebSocket directly. For example:

  • Auto sign/verify
    • Sign/verify events automatically by integrating with rx-nostr-crypto or other arbitrary crypto libraries.
  • Auto adaptive reconnection
    • If the subscription is based on a time relative to its start time, consider it when auto reconnecting.
  • Auto expiration check
    • Based on NIP-40, ignore expired events.
  • REQ queue respecting NIP-11
    • Based on NIP-11, queuing requests if they exceed the limit of subscriptions that can run concurrently.
  • Reactive relay pool
    • On updating "default relays", the subscriptions on default relays is reconstructed on new default relays.
  • Monitoring WebSocket connection
    • For example, it helps you show relay status to users.
  • Lazy connection
    • As default, connection is deferred until it is really needed.
  • Idling connection
    • As default, connections that are no longer needed are automatically disconnected temporarily.

Under the hood, rx-nostr makes use of RxJS, but you don't need to touch it directly. Of course, if you are familiar with RxJS, you can integrate with it for easier and more declarative writing.

Quickstart

npm install rx-nostr rx-nostr-crypto
import { createRxNostr, createRxForwardReq } from "rx-nostr";
import { verifier, seckeySigner } from "rx-nostr-crypto";

import WebSocket from "ws";

const rxNostr = createRxNostr({
  signer: seckeySigner("nsec1..."), // If omitted, rx-nostr uses NIP-07.
  verifier,
  websocketCtor: WebSocket, // You need this if `globalThis.WebSocket` doesn't exist (e.g. Node.js runtime).
});

rxNostr.setDefaultRelays(["wss://nostr.example.com"]);

const rxReq = createRxForwardReq();

// Define a listener.
rxNostr.use(rxReq).subscribe(({ event }) => {
  console.log(event);
});

// Emit a filter to start subscription.
rxReq.emit({ kinds: [1] });

For more information

  • Documentation: https://penpenpng.github.io/rx-nostr/
  • Release notes: https://github.com/penpenpng/rx-nostr/releases

License

MIT