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

dsf-toolkit

v1.0.4

Published

A framework for building distributed applications

Downloads

34

Readme

Distributed Systems Framework

A framework for building intuitive distributed applications as if it were a regular application.

Creating a Distributed Application

Setting Up Your Project

>  npm init -y
>  npm install dsf-toolkit

Building Your Stack- Run the same application on different machines with different peer IDs but same topic(communication stack, your unique string)

1) Identity Service- Provides a unique identity to a peer

import Identity from "dsf-toolkit/servicesLayer/identity/identity.js";

const identity = new Identity({
    static:true, //same identity on restart, false- new identity each time,
    id:"A" //you can override id
}).getIdentity()

console.log(identity)
>  node app.js
{ id: 'A' }

2) Communication Stack- For communicating between peers via messages

import Communication from "dsf-toolkit/messagingLayer/communication/hyperswarm/hyperswarm.js";
import Queue from "dsf-toolkit/messagingLayer/queuing/bypassQueue/bypassQueue.js";
import Router from "dsf-toolkit/protocolLayer/routing/routing.js";

//defining custom topology
let topology = {
  "A": ["B"],
  "B": ["A", "C", "D"],
  "C": ["B", "E"],
  "D": ["B", "E"],
  "E": ["C", "D", "F"],
  "F": ["E"]
}

//communication adapter
let communication = new Communication({
    identity:identity,
    topic:"yourUniqueId",
    allowedNeighbours:new Set(topology[identity.id]) //optional
})

//queuing adapter
let queue = new Queue({
    adapter:communication
})

//routing adapter
let router = new Router({
    identity:identity,
    adapter:queue
})

3) Leader Election- electing k leaders

import Election from "dsf-toolkit/servicesLayer/election/election.js"

let election = new Election({
    identity:identity,
    adapter:router
})

//electing 3 leaders
setTimeout(async()=>{
  let elected = await election.elect(3);
  console.log("[APP] initiator sees result ",elected)
},30000) //we wait for the peers to connect
>  node app.js
initiator sees result  {
  electionId: '01KE4WTG8PNXNMNQSSH18E0T0Y',
  elected: [ 'F', 'E', 'B' ]
}

4) Load Balancer- Peer to peer load balancing

import LoadBalancer from "dsf-toolkit/servicesLayer/loadBalancer/loadBalancer.js";

let loadBalancer = new LoadBalancer({
    identity: identity,
    callback:async(request)=>{
        //simulating a server that takes 10 seconds to process a request
        return new Promise((res, rej)=>{
            setTimeout(()=>{
                res({message:"some response"})
            },10000)
        })
    },
    adapter:router
});

setInterval(async()=>{
        let response = await loadBalancer.send({
            message:"some request"
        })
        console.log("[APP] response",response)

        if(response.status == "FAILURE"){
            console.log("[APP] request was dropped")
        }else{
            console.log("[APP] response", response)
        }
        
    },50) 

5) RateLimiter- drops excess messages

import RateLimiter from "dsf-toolkit/servicesLayer/rateLimiter/rateLimiter.js";

let rateLimiter = new RateLimiter({
    adapter:loadBalancer,
    rate:15 //allow 15 requests per second
})

setInterval(async()=>{
        let response = await rateLimiter.send({
            message:"some request"
        })

        console.log("[APP] response",response)

        if(response){
            if(response.status == "FAILURE"){
                console.log("[APP] request was dropped")
            }else{
                console.log("[APP] response", response)
            }
        }else{
            console.log("[APP] request was rate limited and dropped")
        }
    },50) //an interval of 50 milliseconds results in 20 req/sec

6) Throttler- queues excess messages

import Throttler from "dsf-toolkit/servicesLayer/throttler/throttler.js"

let throttler = new Throttler({
    adapter:loadBalancer,
    rate:15 //allows 15 requests per second
})

setInterval(async()=>{
        let response = await throttler.send({
            message:"some request"
        })
        console.log("[APP] response",response)

        if(response.status == "FAILURE"){
            console.log("[APP] request was dropped")
        }else{
            console.log("[APP] response", response)
        }
    },50) //an interval of 50 milliseconds results in 20 req/sec

7) Local Storage- A key-value storage

import LocalStorage from "dsf-toolkit/servicesLayer/localStorage/localStorage.js";

const localStorage = new LocalStorage({
    identifier: "USERS" // define scope/context
});

localStorage.set("alice", {
    name: "Alice Wonderland",
    age: 28,
    email: "[email protected]",
    role: "admin",
    registered: true
});

console.log(localStorage.get("alice"));

Upcoming Services

  1. local compute
  2. distributed storage
  3. distributed compute
  4. cache
  5. firewall
  6. container orchestration