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

@domecs/rules

v2.0.0

Published

DOMECS rules: a small, safe, data-defined expression language and rule interpreter (M6).

Readme

@domecs/rules

A small, safe, data-defined expression language and rule interpreter for DOMECS (M6).

  • parseExpression — a Pratt parser turning a tiny expression grammar into an AstNode. Never throws; syntax errors come back as { errors: ParseError[] } with an accurate character position. Expressions longer than MAX_EXPRESSION_LENGTH (16384 characters) or nesting deeper than MAX_EXPRESSION_DEPTH (128 levels, counting long operator chains) are parse errors, so rule data cannot overflow the stack.
  • evaluate — a pure, world-agnostic evaluator (AstNode + EvalEnv → number | string | boolean).
  • compileRule / installRules — the world-facing layer that resolves a RuleDef (JSON-shaped: query, when, actions) against real @domecs/core component types and installs it as a world.system(...).

See inline doc comments in src/evaluator.ts and src/rules.ts for the documented behavior around missing fields (skip and fault the entity) and determinism (random() is wired to the per-tick ctx.rand.uniform(), never Math.random).

Writes are checked and atomic. For each entity, actions are evaluated in order — a later action reads the value an earlier one set — against staged writes, which are committed only when every action succeeded; if one fails, the entity is skipped and nothing is written — including when an action's target component is missing from the entity. A write must target an existing field of the same kind (number, string or boolean; a field holding null or undefined takes any of them), and numbers must be finite. Reads see own fields only, and __proto__, constructor and prototype are rejected as field names at compile time. A write that does not change the value does not mark the component changed.

Errors are reported, not swallowed. Type errors that would fail on every evaluation are compile errors: a string or boolean literal (or an operator producing one) where arithmetic, a comparison or a function needs a number, outside code that may not run (the right side of &&/||, ternary branches). Field kinds are not checked at compile time — a component's defaults do not fix them. At run time, a rule that cannot run on an entity — a field it reads is missing, or a write is rejected — skips that entity and attaches a fault to it: Faulted gets an entry with kind rule_eval_failed, source rule:<name> and detail: { rule, message } (the RuleFault type). Any other error is a bug and propagates out of the step.

Rules run as systems named rule:<name>. RuleDef.priority (default 0) places them among other systems; rules of equal priority run in the order of the defs array last passed to update(). A def with an unknown schedule or a non-finite priority is a compile error, and a def repeating an earlier def's name is not installed and is reported under that name. Number literals too large for a double and unknown string escapes (\q) are parse errors.

dt for a fixed rule is the fixed step, but time is the frame's elapsed time, the same in every fixed sub-step of a frame. sin/cos use Math.sin/Math.cos, which are not bit-identical across JS engines (SPEC §8): avoid them in rules that must replay identically elsewhere.

Expressions are compiled once to closures, and a rule skips write staging when no action reads a field an earlier action wrote. A simple rule over 5k entities costs about 2.5× a hand-written system.