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

@momics/dns-sd-shared

v0.1.0

Published

Runtime-agnostic, standards-compliant DNS-SD (mDNS / RFC 6762 + 6763) foundation. No native dependencies.

Readme

@momics/dns-sd-shared

The shared, runtime-agnostic foundation for the @momics/dns-sd library family. Pure TypeScript, zero native or runtime-specific dependencies. It performs no I/O of its own — a runtime package injects a backend and gets the identical public API back.

It contains:

  • the public API types and the createDnsSd factory;
  • a hardened, standards-compliant DNS/mDNS wire codec (RFC 1035 / 6762 / 6763);
  • the runtime-agnostic mDNS engine (query scheduling & back-off, a record cache with TTL expiry and cache-flush handling, known-answer suppression, and the full advertise probe → announce → conflict-resolution → goodbye lifecycle);
  • two backend seams: DatagramTransport (UDP multicast) and DnsSdAdapter (OS resolver);
  • an in-memory loopback transport (a virtual multicast bus) and a shared conformance suite for testing.

Public API

/** Continuously discover service instances. */
browse(opts: BrowseOpts): AsyncGenerator<ServiceAnnouncement, void, void>;

/** Advertise a service on the local network. */
advertise(opts: AdvertiseOpts): Promise<AdvertiseHandle>;

Both are obtained from a DnsSd created via createDnsSd(backend):

import { createDnsSd } from "@momics/dns-sd-shared";

// Runtime with raw UDP (Deno, Node):
const dnsSd = createDnsSd({ transport: myDatagramTransport });

// Runtime that must use the OS resolver (Tauri iOS/Android):
const dnsSd = createDnsSd({ adapter: myDnsSdAdapter });

for await (const svc of dnsSd.browse({ service: { type: "http", protocol: "tcp" } })) {
  // svc.kind is "found" | "resolved" | "updated" | "removed"
}

Stop a browse by break-ing out of the loop, calling the generator's .return(), passing a signal, or setting timeoutMs. Stop an advertisement via the returned handle's stop() (or await using).

Backend seams

A runtime package implements one of these and passes it to createDnsSd.

DatagramTransport (Deno / Node)

interface DatagramTransport {
  readonly family: "IPv4" | "IPv6";
  readonly hostname: string;
  send(data: Uint8Array): Promise<void>;
  receive(): Promise<ReceivedDatagram | null>;
  localAddresses(): string[];
  setMulticastTtl?(ttl: number): void | Promise<void>;
  setMulticastLoopback?(enabled: boolean): void | Promise<void>;
  close(): void | Promise<void>;
}

The shared engine drives the full mDNS protocol over this socket.

DnsSdAdapter (Tauri / native mobile)

interface DnsSdAdapter {
  browseStart(spec: BrowseServiceSpec, sink: ServiceSink): Promise<AdapterBrowseHandle>;
  advertiseStart(spec: AdvertiseServiceSpec): Promise<AdapterAdvertiseHandle>;
  close(): Promise<void>;
}

Here the OS performs mDNS; the adapter just maps OS events to ServiceAnnouncement values via the sink.

Conformance suite

Every runtime package should run the shared conformance suite against its own backend to prove identical behaviour:

import { conformanceCases } from "@momics/dns-sd-shared/testing";
import { createDnsSd } from "@momics/dns-sd-shared";

for (const c of conformanceCases()) {
  myTestRunner.test(c.name, () =>
    c.run({
      createNode: () => createDnsSd({ transport: makeMyTransportOnSharedSegment() }),
      cleanup: async () => {/* close nodes */},
    }));
}

The @momics/dns-sd-shared/testing entry point also exports VirtualBus and LoopbackTransport, an in-memory virtual multicast bus used to test the engine with no network.

Testing this package

deno task test    # Deno
npm run test:node # Node.js (tsc build + run)

License

Dual-licensed under MIT or Apache-2.0, at your option.