New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@stll/conditions

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stll/conditions

A generic boolean/predicate condition engine: schema, evaluate, walk.

Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@stll/conditions

A generic, side-effect-free boolean/predicate condition engine: a typed condition AST, its single evaluator, and a walker.

The package owns one canonical structured-condition shape (compare, predicate, and group nodes combined with and/or and negation) so that different consumers — filters, gating, templates — share one set of operators and semantics and never drift apart. Domain code supplies a small resolve adapter that turns a non-literal operand into a concrete value; the evaluator handles operators, boolean combination, and negation.

import { evaluateCondition, type Condition } from "@stll/conditions";

const condition: Condition = {
  type: "group",
  combinator: "and",
  negated: false,
  children: [
    {
      type: "compare",
      op: "eq",
      left: { type: "path", path: "status" },
      right: { type: "literal", value: "open" },
    },
  ],
};

const result = evaluateCondition(condition, (operand) =>
  operand.type === "path" ? data[operand.path] : undefined,
);

Install

bun add @stll/conditions

API

Everything is exported from the package root (@stll/conditions). The surface is organised into three areas:

  • schema — the condition AST types and Valibot schemas (conditionSchema, conditionNodeSchema, emptyCondition).
  • evaluate — the single evaluator (evaluateCondition, OperandResolver, pruneIncomplete).
  • walk — AST traversal helpers (conditionHasFormula).

License

Apache-2.0

Keywords

ast

FAQs

Package last updated on 29 Jun 2026

Related posts