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.3.0

Published

Pluggable and extensible execution runtime for functional logic.

Readme

neuron-cover640.png

neuron-js

A pluggable, serializable rules engine for functional programming rulesets.

License: MIT Socket Badge Node.js Version Build Status

neuron-js is a lightweight, extensible rules engine designed to execute functional programming logic for other applications in a strictly serializable format. By modeling execution after biological systems—using Neurons as registries and Synapses as executors—it allows you to build, store, and run complex functional rulesets that remain pure JSON.

Perfect for dynamic business rules, automation workflows, and cross-application decision logic.


✨ Features

  • 🛠 Pluggable Architecture: Easily register custom Actions, Conditions, and Parameters.
  • 📦 JSON Serializable: Logic scripts are pure JSON, perfect for database storage or remote transmission.
  • 🧬 Biological Analogy: Intuitive execution model based on neurons, synapses, and rules.
  • Modern Toolchain: Built with Node 24, TypeScript, Biome, and Vitest.
  • 🌓 Dual-Module Support: Native ESM and CommonJS support via tshy.
  • 🪝 Lifecycle Hooks: Comprehensive hook system for monitoring and side-effect management.

🚀 Quick Start

Installation

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

Basic Usage

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

// 1. Initialize the registry
const neuron = new Neuron();

// 2. Setup the executor
const synapse = new Synapse(neuron);

// 3. Define your logic script (JSON-serializable)
const script = {
  id: 'hello-script',
  rules: [
    {
      id: 'rule-1',
      type: 'simple_rule',
      options: {},
      conditions: [
        {
          id: 'is-positive',
          type: 'compare_two_numbers',
          params: [
            { name: 'op1', type: 'simple_number', value: '10' },
            { name: 'comp', type: 'comparator', value: '>' },
            { name: 'op2', type: 'simple_number', value: '0' }
          ]
        }
      ],
      actions: [
        {
          id: 'add-log',
          type: 'add_two_numbers',
          params: [
            { name: 'op1', type: 'simple_number', value: '5' },
            { name: 'op2', type: 'simple_number', value: '5' }
          ]
        }
      ]
    }
  ]
};

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

console.log(result.isSuccessful()); // true
console.log(result.value); // 1 (number of rules executed)

🧬 Core Concepts

Neuron (The Registry)

The Neuron acts as the central hub where all element types (Actions, Conditions, Parameters, Rules) are registered. It ensures the runtime knows how to instantiate any element defined in your scripts.

Synapse (The Executor)

The Synapse is the engine that connects a Neuron registry to an ExecutionScript. It traverses the logic and manages the flow of the ExecutionContext.

Elements

  • Action: An operation to perform (e.g., "SendEmail", "UpdateDatabase").
  • Condition: A logical predicate (e.g., "UserIsAdmin", "ValueIsGreaterThanX").
  • Parameter: Configurable inputs for elements, enabling reusable logic templates.

💾 Execution Context & State

The ExecutionContext is a shared state object that persists throughout the entire execution of a script. It allows Actions and Conditions to communicate and share data.

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

Using State in Actions

Actions can read from the context and return an updated context to pass information to subsequent rules.

// Example: An action that stores a value in the state
execute(context: ExecutionContext): ExecutionResult {
  const newState = { ...context.state, lastCalculation: 42 };
  return new ExecutionResult(true, { ...context, state: newState });
}

🛠 Development

We use a modern toolchain for high performance and developer ergonomics:

Commands

yarn test    # Run test suite
yarn lint    # Check for linting issues
yarn build   # Generate ESM/CJS bundles

📄 License

MIT © SebaSOFT