weiroll / weiroll.js

A high-level javascript transpiler for weiroll
https://weiroll.github.io/weiroll.js/
MIT License
53 stars 10 forks source link

Subplanner support #22

Closed Arachnid closed 3 years ago

Arachnid commented 3 years ago

This PR adds support for 'subplanners' - nested executions of weiroll that share their state arrays but have distinct command lists.

Example usage:

const planner = new Planner();

const subplanner = new Planner();
const sum = subplanner.add(Math.add(1, 2));

planner.addSubplan(SubcommandContract.execute(subplanner, subplanner.state));
planner.add(Events.logUint(sum));

const { commands, state} = planner.plan();

Return values from one subplan can be used in the parent scope, and even in other subplans. The planner constructs command lists for subplanners and inserts them into the state.

github-actions[bot] commented 3 years ago

size-limit report 📦

Path Size
dist/weiroll.js.cjs.production.min.js 31.03 KB (-6.1% 🔽)
dist/weiroll.js.esm.js 29.17 KB (-6.4% 🔽)