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 🙏

© 2024 – Pkg Stats / Ryan Hefner

anothersequencer

v0.1.9

Published

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.

Downloads

23

Readme

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' //or copy the html
//import {Sequencer} from './Sequencer.js'
//in HTML: <script type='module' src='./Sequencer.js></script>
//or for lazy: 
//document.head.insertAdjacentHTML(`<script type='module' src='./Sequencer.js></script>`)

let sequencer = new Sequencer();

//simple sequences will pass the previous result along in the order of the array
let sequence1 = [ 
    (input)=>{console.log('a',input); return 1;},
    (input)=>{console.log('a',input); return 2;}, //should log 1
    async (input) => {console.log('a',input); return 3;} //should log 2
];

sequencer.addSequence('a',sequence1); //or .add

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

//complex
let sequence2 = { //create a sequence object or array, can mix and match for each layer as well
    operation:(input)=>{ //.operation, .op, .f, .fn, .callback all work
        console.log('b',input);
        return 5;
    },
    next:[ //Calls here receive the parent result.
        {
            operation:(input)=>{
                console.log('b',input);
                return 6;
            },
            frame:true // can execute with requestAnimationFrame
            next:async (input)=>{console.log('b',input);} //can end with a function
        },
        {
            tag:'repeater'
            delay:1000, //ms delay for this call
            operation:(input)=>{
                console.log('b',input);
                return 7;
            },
            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
        }
    ]
}

sequencer.addSequence('b',sequence2);

sequencer.runSequence('b',4);


//add a triggered function on result
sequencer.subscribe('repeater',(res)=>{console.log('subscribed',res)});
//You could even, say, subscribe one tagged sequence to another tagged sequence.

sequencer.unsubscribeFromOperation('repeater',sub); //or .unsubscribe //leave sub blank to remove all triggers. 

Other functions less obvious to use:

sequencer.getSequence( //or .get
    name,
    layer //optional
);
sequencer.appendSequence( // or .append
     name, //name of sequence
    layer, //layer 2 is the second layer, etc. leave blank to append on first layer
    setting={ //object or function, functions cannot have more layers added
    //operation:(result) => {} //callback for the sequence, takes the previous result
    //delay:undefined, //set to a millisecond value
    //frame:undefined //setframe:true depending on if you want frame-timed async (which won't run if you are outside of the browser context)
    //tag:'xyz', //make subscribable outputs on this layer
    //repeat:3 //recursive:3 //repeater or recursive repeater. Recursion passes this layer's output back in rather than the parent layer
    tab)
    }, 
    index //if you are appending to .next of an operation in a particular sequence layer you can use  this. Leave blank to just add the setting to the specified layer instead
)
sequencer.removeSequence( //or .remove
    name,
    layer, //optional
    index //optional
);
//this is used recursively by runSequence otherwise to iterate a layer
sequencer.runSequenceLayer(
    layer,
    previousResult
)

Joshua Brewster --- AGPL v3.0