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

@flux-control/modbus-schema

v0.1.2

Published

Device-agnostic Effect Schema generators for Modbus register values, with both Effect-native and synchronous APIs.

Downloads

434

Readme

@flux-control/modbus-schema

Device-agnostic Effect Schema generators for Modbus register values. This library produces bidirectional schemas between 16-bit Modbus wire values (UInt16 / Int16) and domain types. Every generator returns both Effect-native (decode / encode) and synchronous (decodeSync / encodeSync) APIs, so the Effect runtime is optional for consumers.

For the complete API reference, see the GitHub Pages documentation.

This project is under active development. Its API may change before the 1.0 release.

Install

bun add @flux-control/modbus-schema

Requires effect as a peer dependency.

Quick start

Effect-native API

import { Effect } from 'effect';
import { makeScaledParam } from '@flux-control/modbus-schema';

const entry = makeScaledParam(0x0102, 0.1, {
  name: 'Maximum Output Frequency',
  unit: 'Hz',
  range: '4.8~599.0',
  default: '50.0',
});

const program = Effect.gen(function* () {
  const value = yield* entry.decode(500);
  console.log(value); // 50.0
  const wire = yield* entry.encode(60.0);
  console.log(wire); // 600
});

Effect.runSync(program);

Synchronous API

import { makeScaledParam } from '@flux-control/modbus-schema';

const entry = makeScaledParam(0x0102, 0.1, {
  name: 'Maximum Output Frequency',
  unit: 'Hz',
  range: '4.8~599.0',
  default: '50.0',
});

const value = entry.decodeSync(500); // 50.0
const wire = entry.encodeSync(60.0); // 600

Factory functions

Each factory returns a ParamEntry with schema, decode, encode, decodeSync, encodeSync, and formatted.

| Factory | Description | | ---------------------------------------------------------- | ---------------------------------------------------- | | makeParam(register, meta) | Simple UInt16 pass-through | | makeScaledParam(register, factor, meta) | Unsigned scaled value | | makeSignedScaledParam(register, factor, meta) | Signed scaled value using two's complement | | makeEnumParam(register, labels, meta) | Enum label ↔ wire integer | | makeBitfieldParam(register, flagsClass, bitLayout, meta) | Boolean flags packed into a word | | makeLookupParam(register, labels, fallback, meta) | Decode-only lookup table with fallback | | fromConfig(config) | Dispatch to the correct factory from a ParamConfig |

Development

| Action | Command | | ----------- | ---------------------------- | | Install | bun install | | Type-check | bun run typecheck | | Test | bun test | | Run example | bun run examples/<name>.ts | | Build | bun run build |

No build step required for development — noEmit is on; Bun runs .ts directly.

Source layout

index.ts                     — Re-exports all public API from src/
src/
  index.ts                   — Schema engine: factories, config types, fromConfig, wire primitives
  engine.test.ts             — Unit tests for all factories and sync APIs
examples/
  basic.ts                   — Effect + synchronous API usage
  branded-types.ts           — Domain brands with scaled/signed parameters
  from-config.ts             — Declarative ParamConfig dispatch via fromConfig
  bitfield-flags.ts          — Read-modify-write flag registers
  lookup-table.ts            — Decode-only fault/alarm code lookups
  register-map.ts            — Compose multiple entries into a typed snapshot
  error-handling.ts          — Parse error handling in Effect and sync APIs

License

GPL-3.0