Javascript function sequencing
Quick and dirty script sequencer. Create function trees, add async/requestAnimationFrame or delays, and subscribe to tagged outputs in the trees.
Sequences are created from basic javascript structures with some required and optional variables as specified below, so it's visually/syntactically as intuitive and efficient as possible to write once you get the hang of it (hopefully).
npm i anothersequencer
For a similarly structured but more technical Acyclic Graph Node sequencer (i.e. trees and forests) with promise-returning sequences and forward/backprop + more simple hierarchical programming utilities: AcyclicGraph.js
Usage:
import {Sequencer} from 'anothersequencer'
let sequencer = new Sequencer();
let sequence1 = [
(input)=>{console.log('a',input); return 1;},
(input)=>{console.log('a',input); return 2;},
async (input) => {console.log('a',input); return 3;}
];
sequencer.addSequence('a',sequence1);
sequencer.runSequence('a', 0);
let sequence2 = {
operation:(input)=>{
console.log('b',input);
return 5;
},
next:[
{
operation:(input)=>{
console.log('b',input);
return 6;
},
frame:true
next:async (input)=>{console.log('b',input);}
},
{
tag:'repeater'
delay:1000,
operation:(input)=>{
console.log('b',input);
return 7;
},
repeat:3,
next:'a'
}
]
}
sequencer.addSequence('b',sequence2);
sequencer.runSequence('b',4);
sequencer.subscribe('repeater',(res)=>{console.log('subscribed',res)});
sequencer.unsubscribeFromOperation('repeater',sub);
Other functions less obvious to use:
sequencer.getSequence(
name,
layer
);
sequencer.appendSequence(
name,
layer,
setting={
tab)
},
index
)
sequencer.removeSequence(
name,
layer,
index
);
sequencer.runSequenceLayer(
layer,
previousResult
)
Joshua Brewster --- AGPL v3.0