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

@sebasoft/neuron-js

v0.5.2

Published

AI-friendly TypeScript rules engine for serializable JSON business rules and deterministic workflow decisions.

Readme

neuron-js

AI-friendly TypeScript rules engine for serializable JSON business rules and deterministic workflow decisions.

License: MIT Socket Badge Node.js Version Build Status

neuron-js lets teams define business rules and workflow decisions as pure JSON, execute them deterministically in Node.js or the browser, and extend the rule vocabulary with TypeScript actions, conditions, parameters, rules, and lifecycle hooks.

Use it when hardcoded if/else logic is too rigid, but a heavyweight workflow or BPMN platform is too much machinery.

Links


Why neuron-js?

Use neuron-js when:

  • Business rules need to be stored, versioned, audited, or changed without redeploying code.
  • Backend and frontend code need to share the same deterministic rule definitions.
  • AI assistants or workflow tools generate JSON rules that still need developer-owned validation and execution boundaries.
  • Product, pricing, eligibility, routing, or automation decisions change faster than application deployments.
  • A full workflow platform is too heavy, but hardcoded conditional logic is too brittle.

Do not use neuron-js when a simple hardcoded condition is clearer and rarely changes, when arbitrary user code execution is required, or when you need a full BPMN/process orchestration platform.


✨ Features

  • 🛠 Pluggable TypeScript registry: Register custom Actions, Conditions, Parameters, and Rules.
  • 📦 JSON business rules: Store, transmit, version, and audit logic as serializable JSON.
  • Deterministic execution: Run predictable workflow and business decisions in Node.js or the browser.
  • 🪝 Lifecycle hooks: Monitor script, rule, action, and error events around execution.
  • 🌓 Dual-module support: Native ESM and CommonJS bundles via tshy.

🚀 Quick Start

Installation

yarn add @sebasoft/neuron-js
# or
npm install @sebasoft/neuron-js

Executable rule example

import { Neuron, Synapse } from '@sebasoft/neuron-js';

const neuron = new Neuron();
const synapse = new Synapse(neuron);

const script = {
  id: 'pricing-decision',
  rules: [
    {
      id: 'vip-discount-rule',
      type: 'simple_rule',
      options: {},
      conditions: [
        {
          id: 'minimum-order-value',
          type: 'compare_two_numbers',
          options: {},
          params: [
            { id: 'order-total', name: 'op1', type: 'simple_number', value: '125', options: {} },
            { id: 'comparison', name: 'comp', type: 'comparator', value: '>', options: {} },
            { id: 'threshold', name: 'op2', type: 'simple_number', value: '100', options: {} }
          ]
        }
      ],
      actions: [
        {
          id: 'calculate-discount',
          type: 'add_two_numbers',
          options: {},
          params: [
            { id: 'base-discount', name: 'op1', type: 'simple_number', value: '10', options: {} },
            { id: 'vip-bonus', name: 'op2', type: 'simple_number', value: '5', options: {} }
          ]
        }
      ]
    }
  ]
};

const context = { messages: [], state: {} };
const result = synapse.execute(script, context);

console.log(result.isSuccessful()); // true
console.log(result.value); // 1 rule executed
console.log(result.context.messages.map((message) => message.text)); // includes "Sum result: 15"

🧬 Core Concepts

Neuron: the registry

The Neuron registry knows which parameter, condition, action, and rule types are available. Applications keep control of this registry so generated or stored JSON can only use developer-approved capabilities.

Synapse: the executor

The Synapse engine connects a Neuron registry with a serializable script and an execution context. It evaluates rules, applies actions, and emits lifecycle hooks.

Rule

A Rule is a logical unit containing conditions and actions.

  • No Conditions: the rule is treated as always eligible.
  • No Actions: the rule evaluates conditions but performs no operation.

Elements

  • Action: An operation to perform, such as writing to context, calculating a value, or triggering an approved side effect.
  • Condition: A predicate that decides whether a rule should run.
  • Parameter: A serializable input for actions and conditions.

💾 Execution Context & State

The ExecutionContext is a shared state object that persists through script execution. Actions and conditions can read from it, and actions can return updated context for later rules.

interface ExecutionContext {
  messages: { type: string; text: string }[];
  state: Record<string, any>;
}

Roadmap-aligned docs

The current public surface includes installation, positioning, core concepts, runtime architecture, and runnable examples.

Available adoption assets:

Planned next adoption assets:

  • Comparison and migration pages: NJS-GROWTH-05

🛠 Development

We use a modern toolchain for high-signal development:

Commands

yarn test    # Run test suite
yarn lint    # Check linting and formatting
yarn examples # Build and verify runnable examples
yarn build   # Generate ESM/CJS bundles
yarn docs:build # Build API docs and VitePress site

📄 License

MIT © SebaSOFT