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

@dressed/ws

v0.5.0

Published

Communicate with the Discord Gateway.

Downloads

429

Readme

@dressed/ws

Interact with the Discord gateway. Handles connecting, disconnecting, sharding.

📦 Install

bun add dressed @dressed/ws

🚀 Usage

Connecting

import { createConnection } from "@dressed/ws";

const connection = createConnection({ intents: ["DirectMessages"] });
connection.onReady((data) => console.log(data.user.username, "is ready"), {
  once: true,
});

Like Dressed core, it will use the DISCORD_TOKEN environment variable for the token by default.

The connection will automatically check if it should reshard. The interval and threshold are customizable within the shards option in createConnection.

[!TIP] If you want to disable the auto-resharding system, set shards.reshardInterval to -1.

To manually reshard, you can use connection.shards.reshard(n).

Caching

Dressed will cache responses from the functions you provide in the first createCache prop.

The cache provides an object (getters) of all API interfacing functions you'd likely want to cache.

import { createCache, getters } from "@dressed/ws/cache";

const myCache = createCache({
  ...getters,
  async findUser(id: string) {
    const res = await fetch(`https://example.com/api/user?id=${id}`);
    return res.json();
  },
});
const app = await cache.getApp();
const user = await myCache.findUser("123");

The get function must return an object with a state. The state can be hit, stale, or miss.

  • A hit or stale state must also include a value which will be returned.
  • If the state is stale, the cache value will be refetched in the background.
  • For a miss, the cache value will be fetched and the function will wait for it to finish.

Checkout this example to see some custom logic using Redis.

The default logic has some timing config which can be updated by using the defaultLogic function in the logic option.

Doing this will cause the returned type to be turned into a partial where only the props in your array are excluded.

The reason that all others aren't omitted completely is because a miss will return the whole data from the response.

import { createCache, getters } from "@dressed/ws/cache";

const cache = createCache(getters, { desiredProps: { getUser: ["username"] } });
const user = await cache.getUser("123456789012345678");
user.username; // string
user.id; // string | undefined (normally this would be a string)