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

station-expressions

v1.0.4

Published

Pure, deterministic expression AST + evaluator + validator for Station dynamic broadcasts

Readme

station-expressions

Pure, deterministic expression AST + evaluator + validator + parser used by Station's dynamic broadcast input mappings and when guards.

This package is a leaf — it has no dependencies on the rest of Station, so it's safe to use anywhere a small, side-effect-free expression language is needed.

Why a separate language?

Dynamic broadcasts need user-supplied logic that can be persisted, validated server-side, round-tripped through JSON, and run inside Station's reconcile loop without giving users a JS sandbox. The expression language has:

  • No I/O, no time, no randomness — pure functions of input.
  • No loops, no recursion, no user-defined functions — bounded complexity, no DoS surface.
  • JSON-serializable AST — the persisted form is the AST. A string syntax exists for the UI / playground, compiled to AST.
  • Static type checking — validate expressions against signal inputSchema / outputSchema before save.

If you can't express something in this language, write a code-defined signal that does the logic in TypeScript and reference it from your broadcast graph. The signal is the unit of arbitrary code; expressions just connect them.

Install

pnpm add station-expressions

API

import {
  evaluate,
  validate,
  parse,
  stringify,
  type ExprNode,
  type SchemaField,
} from "station-expressions";

Evaluate an AST against a context

const node: ExprNode = {
  kind: "op",
  op: ">",
  args: [
    { kind: "ref", path: ["input", "amount"] },
    { kind: "lit", value: 100 },
  ],
};

evaluate(node, { input: { amount: 250 }, upstream: {} });
// → true

Validate against schemas

validate(node, {
  inputSchema: {
    type: "object",
    properties: { amount: { type: "number" } },
  },
  upstreamSchemas: {},
  expectedSchema: { type: "boolean" },
});
// → { ok: true, errors: [] }

Parse string syntax

parse(`input.amount > 100 && input.user.tier == "premium"`);
// → { kind: "op", op: "&&", args: [...] }

Stringify back

stringify(node);
// → '(input.amount > 100)'

ExprNode shape

type ExprNode =
  | { kind: "ref"; path: string[] }
  | { kind: "lit"; value: unknown }
  | { kind: "tmpl"; parts: (string | ExprNode)[] }
  | { kind: "op"; op: BinaryOp | UnaryOp; args: ExprNode[] }
  | { kind: "obj"; entries: Record<string, ExprNode> }
  | { kind: "arr"; items: ExprNode[] };

Reference paths

| Path | Resolves to | |------------------------------|----------------------------------------------| | input.foo | The broadcast's trigger input, field foo | | upstream.nodeName.field | An upstream node's output | | nodeName.field | Shorthand for upstream.nodeName.field |

Missing paths return undefined rather than throwing. Use validate to catch missing-property errors at save time.

Operators

==, !=, >, <, >=, <=, &&, ||, !, +, -, *, /.

+ is overloaded: if either operand is a string, the result is a string concatenation; otherwise numeric addition. Comparison operators use strict equality (===).

Determinism guarantees

  • evaluate is total over well-typed inputs that pass validate — it never throws on type mismatches at runtime if the validator passed against the real schemas.
  • Bounded by MAX_NODES = 10_000 — runaway expressions throw ExpressionEvalError rather than spinning.
  • No closures, no captured state, no global access.

License

MIT