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

@axi-engine/instructions

v0.2.1

Published

[![NPM version](https://img.shields.io/npm/v/@axi-engine/instructions.svg)](https://www.npmjs.com/package/@axi-engine/instructions)

Readme

@axi-engine/instructions

NPM version

Description

@axi-engine/instructions is a declarative execution engine designed for game logic and scripting. It allows you to define application logic using JSON-serializable objects, making it ideal for quests, dialogues, cutscenes, and AI behaviors.

It works in tandem with @axi-engine/expressions for logic evaluation. It relies on core interfaces from @axi-engine/utils and pairs perfectly with @axi-engine/fields for concrete data storage implementations.

Installation

npm install @axi-engine/instructions

Core Concepts

  • Instruction: A plain JavaScript object that defines an actionable operation (e.g., set, if, log).
  • DataStorage: An interface extending DataSource ({ get, set, delete, ... }) that allows instructions to read and modify the application state.
  • InstructionResolver: The core engine that processes Instruction objects within a given context, delegating execution to specific handlers.

Usage

1. Configuration

Use the builder to create an InstructionResolver. You can include standard sets of instructions or add custom ones.

import {configureInstructions} from '@axi-engine/instructions';

// Create a resolver with all standard instructions (Data, Logic, Utils)
const resolver = configureInstructions()
  .withDefaults()
  .build();

2. Execution

To execute instructions, you need a context that provides access to your Data Storage and Expression Evaluator.

const context = {
  storage: () => myDataStorage,       // Implementation of DataStorage (e.g., from @axi-engine/fields)
  expressions: () => myEvaluator,     // Instance of ExpressionEvaluator
  instructions: () => resolver        // Self-reference for recursive instructions
};

const script = [
  {log: "Starting..."},
  {create: {field: "quest/status", var: {value: "started"}}}
];

await resolver.execute(script, context);

Built-in Instructions

Here are the core instruction types available out of the box.

| Type | Example | Description | |:-------------|:------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------| | log | { "log": ["Welcome ", { "path": "player.name" }] } | Outputs a message or variable values to the system log. | | create | { "create": { "field": "quest.status", "var": { "value": "active" } } } | Creates a new variable. Throws an error if the path already exists. | | set | { "set": { "field": "player.hp", "var": { "value": 50 } } } | Updates an existing variable. Throws an error if the path does not exist. | | upset | { "upset": { "field": "meta.save_time", "var": { "value": 12345 } } } | Updates a variable if it exists, or creates it if it doesn't (Upsert). | | delete | { "delete": "inventory.temp_items" } | Removes a variable or group at the specified path. | | if | { "if": { "condition": { "literal": true }, "then": [ ... ], "else": [ ... ] } } | Executes a list of instructions based on a boolean expression. | | switch | { "switch": { "check": { "path": "class" }, "cases": [ { "case": { "value": "mage" }, "do": [...] } ] } } | Selects a block of instructions to execute by matching a value against defined cases. |

Extending with Custom Instructions

todo

License

MIT