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

ds2408

v1.0.0

Published

DS2408 1-Wire 8-channel GPIO chip access via Linux SysFS (1-wire kernel driver). Zero runtime dependencies, ESM, TypeScript types.

Readme

ds2408

DS2408 1-Wire 8-channel I/O chip driver for Node.js, using the Linux kernel's w1-gpio / w1-therm sysfs interface.

npm CI

  • Zero runtime dependencies
  • ESM, TypeScript types
  • Node 22+

Requirements

  • Linux host with the 1-Wire kernel modules loaded (w1-gpio, wire).
  • DS2408 attached on the 1-Wire bus, exposed under /sys/bus/w1/devices/29-*.
  • Process needs read/write access to those sysfs files (usually root, or a udev rule).

Install

npm install ds2408

Usage

import { DS2408, findAttachedDevices } from 'ds2408';

// Auto-select the first attached DS2408.
const ds = await DS2408.open();

// Or pass an explicit serial.
// const ds = await DS2408.open('29-0000017d3b86');

// Read live pin levels.
console.log('state:', (await ds.readState()).toString(2).padStart(8, '0'));

// Drive specific bits low (sink), float others (release to external pull-up).
await ds.sinkOutputs(0b0000_0011);  // channels 0 and 1 sink
await ds.floatOutputs(0b1111_1100); // channels 2..7 float

// Read the current output latch.
console.log('output:', await ds.readOutput());

// React to edges on input pins.
const off = ds.onActivity((activity, state) => {
  console.log(`activity=${activity.toString(2)} state=${state.toString(2)}`);
});
ds.startActivityLoop({ loopDelay: 50 });

// Later …
await ds.stopActivityLoop();
off(); // detach the listener

API

DS2408.open(serial?, options?)

Async factory. Reads the current output-latch register before returning so the instance is consistent.

| option | type | default | description | | ------------------- | ------ | ----------------------------- | ---------------------------------------------------------- | | verificationLoops | number | 2 | Consecutive identical reads needed before returning a value. Filters transient mid-update values. | | devicesDir | string | /sys/bus/w1/devices | Sysfs root. Override for tests. |

findAttachedDevices(devicesDir?)

Returns the serial numbers of all DS2408 chips currently on the bus.

Reading

  • readState() — live PIO pin levels (1 = high, 0 = low).
  • readOutput() — current output-latch register (and updates the internal cache).
  • readControl()status_control byte.
  • readCondSearchMask() / readCondSearchPolarity() — conditional-search registers.
  • pollActivity() — read & write-clear the activity byte; returns { activity, state }.

Writing

  • setOutput(byte) — write the entire output-latch byte (0..255). Bits set to 0 sink the pin; bits set to 1 float it.
  • sinkOutputs(mask) / floatOutputs(mask) / maskedSetOutputs(mask, value) — manipulate outputs relative to the cached state.
  • setControl(byte) / setControls({ PLS, CT, ROS, PORL }, read = true) — write the status-control byte. setControls modifies only the bits you specify (when read = true).

Activity loop

  • startActivityLoop({ loopDelay = 100 }) — start polling the activity register on a timer; non-zero readings notify all onActivity listeners.
  • stopActivityLoop() — stop the loop; resolves once the in-flight tick (if any) finishes.
  • onActivity(listener) — register a listener; returns a removal function.
  • isActivityLoopRunning — true while the loop is active.

License

MIT — see LICENSE.