Javascript function sequencing
Quick and dirty script sequencer. Create function trees, add async/requestAnimationFrame or delays, and subscribe to tagged outputs in the trees.
npm i anothersequencer
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);}
},
{
delay:1000,
operation:(input)=>{
console.log('b',input);
return 7;
},
repeat:3,
next:'a'
}
]
}
sequencer.addSequence('b',sequence2);
sequencer.runSequence('b',4);
let sub = sequencer.subscribeToOperation('anotheroperation',onResult);
sequencer.unsubscribeFromOperation('anotheroperation',sub);
Other functions less obvious to use:
sequencer.getSequence(
name,
layer
);
sequencer.appendSequence(
name,
layer,
setting={
},
index
)
sequencer.removeSequence(
name,
layer,
index
);
sequencer.runSequenceLayer(
layer,
previousResult
)