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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hackthedev/dsync

v1.0.8

Published

dSync stands for decentralized synchronization. The goal is to have an **easy way** for listening to events and emitting events to create a decentralized network. In order for this to work you need to know and add other nodes like in the example below. Th

Readme

dSync

dSync stands for decentralized synchronization. The goal is to have an easy way for listening to events and emitting events to create a decentralized network. In order for this to work you need to know and add other nodes like in the example below. The usage and syntax was inspired by socket.io which is why it is pretty similar to it.


Init

Straight up dSync requires express to work. When initializing dSync using new dSync() you need to provide a project name. This way a single node can be part of multiple decentralized networks without clashing together.

import express from "express";
import dSync from "@hackthedev/dsync";

const app = express();
let sync = new dSync("your-project-name", app)

Adding peers

Afterwards you need to add the other nodes. In my example im adding my own localhost instance for testing. Its important that the url is reachable.

[!IMPORTANT]

Do not add yourself to the peers in production, as this was done for testing only.

sync.addPeer("http://localhost:2052")

Listening for events

To listen for events you could do something like below. This example uses responses and rate limit options {ipRequestLimit: 1, requestLimit: 10}. The numbers represent the maximum requests per minute. Everything above will be rejected with a error similar to Rate limit exceeded.

The ipRequestLimit is bound to the node emitting this event. In order to prevent further abuse and bypasses like VPNs or Proxy Servers, there is a general rate limit, requestLimit.

sync.on("ping", { ipRequestLimit: 1, requestLimit: 10 }, (payload, response) => {
    console.log("payload:", payload)
    response({ pong: true, from: "B" })
})

Emitting global events

You can easily emit events to all known peers with the following example:

sync.emit("ping", { hello: "A and C" }, (res) => {
    console.log("Response:", res)
})

Emitting to specific peers

To emit to specific peers you can add an array called peers like this: peers: ["http://localhost:2052"] and it will only emit to these peers. This is helpful if you target specific peers.

sync.emit("ping", { 
    hello: "A and C", 
    peers: ["http://localhost:2052"]
}, (res) => {
    console.log("Response:", res)
})

Example Result

Based on the two examples above it will result in the following output:

payload:  { hello: 'A and C' } // receiver
Response: { url: 'http://localhost:2052', data: { pong: true, from: 'B' } } // receiver response on sender

Handling Rate Limits

On default when a rate limit is reached it will automatically respond with a rate limit error and cancel further execution. If you want to catch the rate limit, you can supply a parameter called handleRateLimit and set it to true. This way its execution continues, and you can cache the rate limit, like ipRateLimited or rateLimited.

You can also get the rate limited IP address using payload.rateLimitedIP. Optionally you can send a response back.

The idea of this is that you could for example set high rate limits, and if someone reaches the ip rate limit you could automatically create penalties or block a server for some time. The possibilities are endless here.

sync.on("ping", { ipRequestLimit: -1, requestLimit: 10, handleRateLimit: true }, (payload, response) => {
    if (payload.ipRateLimited) {
        console.log(payload.rateLimitedIP)
        response({ error: "IP Rate Limit reached!" })
        return;
    }
    if (payload.rateLimited) {
        console.log(payload.rateLimitedIP)
        response({ error: "Rate Limit reached." })
        return;
    }

    console.log("payload:", payload)
    response({ pong: true, from: "B" })
})