New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

anothersequencer

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anothersequencer - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

package.json
{
"name": "anothersequencer",
"version": "0.1.2",
"version": "0.1.3",
"description": "Simple script tree sequencer in javascript. Allows creating fairly complex trees of sync/async functions or requestAnimationFrame functions with optional delays, as well as subscribing to particular outputs in the tree at any time.",

@@ -5,0 +5,0 @@ "main": "sequencer.js",

@@ -25,5 +25,6 @@ ## Javascript function sequencing

sequencer.addSequence('a',sequence1);
sequencer.addSequence('a',sequence1); //or .add
sequencer.runSequence('a', 0); //these run async
sequencer.runSequence('a', 0); //or .run
//these run async

@@ -51,2 +52,3 @@ //complex

},
repeat:3, //repeat before moving on, 'recursive' does the same but passes the repeater output back to itself rather than the parent input
next:'a' //or can end with another sequence tag

@@ -64,6 +66,6 @@ }

let sub = sequencer.subscribeToOperation('anotheroperation',onResult); //adds a triggered function on result
let sub = sequencer.subscribeToOperation('anotheroperation',onResult); //or .subscribe //adds a triggered function on result
//You could even, say, subscribe one tagged sequence to another tagged sequence.
//sequencer.unsubscribeFromOperation('anotheroperation',sub); //leave sub blank to remove all triggers.
sequencer.unsubscribeFromOperation('anotheroperation',sub); //or .unsubscribe //leave sub blank to remove all triggers.

@@ -75,3 +77,3 @@ ```

```js
sequencer.getSequence(
sequencer.getSequence( //or .get
name,

@@ -82,3 +84,3 @@ layer //optional

```js
sequencer.appendSequence(
sequencer.appendSequence( // or .append
name, //name of sequence

@@ -95,3 +97,3 @@ layer, //layer 2 is the second layer, etc. leave blank to append on first layer

```js
sequencer.removeSequence(
sequencer.removeSequence( //or .remove
name,

@@ -98,0 +100,0 @@ layer, //optional

@@ -178,2 +178,55 @@ //Simple script sequencer

async runSequenceLayer(layer,previousResult) {
let run = async (o,prev,tick=1) => {
let result = await o.operation(prev);
if(o.tag) this.state.setState(o.tag,result);
if(typeof o.repeat === 'number') { //repeats a call with the first result
let i = tick;
while(i < o.repeat) {
if(o.delay) {
setTimeout(async ()=> {
if(o.frame) {
requestAnimationFrame(async ()=>{
i++;
await run(o,prev,i);
});
}
else {
i++
await run(o,prev,i);
}
}, o.delay);
break;
}
else result = await o.operation(prev);
i++;
}
if(i === o.repeat && o.next) await this.runSequenceLayer(o.next,result);
} else if (typeof o.recursive === 'number') { //repeats a call but passes new results back in
let i = tick;
while(i < o.recursive) {
if(o.delay) {
setTimeout(async ()=> {
if(o.frame) {
requestAnimationFrame(async ()=>{
i++;
await run(o,result,i);
});
}
else {
i++
await run(o,result,i);
}
}, o.delay);
break;
}
else result = await o.operation(prev);
i++;
}
if(i === o.recursive && o.next) await this.runSequenceLayer(o.next,result);
}
else if(o.next) await this.runSequenceLayer(o.next,result);
}
if(typeof layer === 'function') { await layer(previousResult); } //can set functionsi in the .next position

@@ -191,5 +244,3 @@ else if (typeof layer === 'string') { this.runSequence(layer,previousResult); } //can set sequences in the .next position by name

requestAnimationFrame(async ()=>{
let result = await o.operation(previousResult);
if(o.tag) this.state.setState(o.tag,result);
if(o.next) await this.runSequenceLayer(o.next,result);
run(o,previousResult);
});

@@ -201,5 +252,3 @@ }, o.delay)

async () => {
let result = await o.operation(previousResult);
if(o.tag) this.state.setState(o.tag,result);
if(o.next) await this.runSequenceLayer(o.next,result);
run(o,previousResult);
},

@@ -213,11 +262,7 @@ o.delay

requestAnimationFrame(async ()=>{
let result = await o.operation(previousResult);
if(o.tag) this.state.setState(o.tag,result);
if(o.next) await this.runSequenceLayer(o.next,result);
run(o,previousResult);
});
}
else {
let result = await o.operation(previousResult);
if(o.tag) this.state.setState(o.tag,result);
if(o.next) await this.runSequenceLayer(o.next,result);
run(o,previousResult);
}

@@ -227,5 +272,3 @@ }

} else if (typeof layer === 'object') {
let result = await layer.operation(previousResult);
if(layer.tag) this.state.setState(layer.tag,result);
if(layer.next) await this.runSequenceLayer(layer.next,result);
run(layer,previousResult);
}

@@ -232,0 +275,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc