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 🙏

© 2025 – Pkg Stats / Ryan Hefner

get-flow

v0.3.0

Published

Flow Control Utility

Readme

get-flow

Node.js Flow Control Utility, powerful and easy to use

Installation

$ git clone --branch=master git://github.com/enricostara/get-flow.git
$ cd get-flow
$ npm install

Coding

Function runSeries(taskList, callback, ...) runs an Array of tasks - and yes, you can mix synchronous and asynchronous tasks! - in series, calling back when done or immediately if an exception occurs.

  • Each task must be a sync or async Function and all the async tasks must have the first argument named callback in order to be recognised as asynchronous.

  • Synchronous task will be internally executed surrounded by a try/catch statement, any exception stops the flow and it will be passed to the main callback as first argument.

  • ASynchronous task must manage any exception internally and propagate it to the callback as first argument

  • The arguments callback and tasks are mandatory (callback can be null but in place anyway), the subsequent arguments (if any) will be passed only to the first task .

See the following example where [sync, async, sync] tasks are executed in series:

var flow = require('get-flow');

function multiply(x, y) {
    return x * y;
}

function addMillis(callback, x) {  // for ASYNC task the first argument must be the callback and be named 'callback'
    var start = new Date().getTime();
    setTimeout(function () {
        var millis = new Date().getTime() - start;
        callback(null, x + millis);
    }, 100);
}

function sqrt(x) {
    return Math.sqrt(x);
}

flow.runSeries(
    [   // tasks series
        multiply, // sync
        addMillis, // async
        sqrt  // sync again
    ],
    function(ex, result) {    // a proper callback when the last task (sqrt) is done
        console.log('no exception, (ex == null) = %s ', ex == null);
        console.log('result = %s', result);
        var assert = require('assert');
        assert.equal(result >= 10, true);
    },
    2, 3 // x and y passed at first task (multiply)
);

Function retryUntilIsDone(callback, retriesLimit, task, ...) calls the given async task until succeeds or the retries limit has been reached (the default is 10 attempts)

All the arguments are mandatory (callback and retriesLimit can be null but in place anyway), the subsequent arguments (if any) will be passed to the task.

See the following example

var flow = require('get-flow');

var i = 0;

function task(callback, input) {
    setTimeout(function () {
        i++;
        if (i === 5) {
            callback(null, input + i);
        } else {
            callback('err')
        }
    }, 10);
}

flow.retryUntilIsDone(
    function (ex, result) { // a proper callback
        console.log('no exception, (ex == null) = %s ', ex == null);
        console.log('result = %s', result);
        var assert = require('assert');
        assert.equal(result, 15);
    },
    null, // retries limit will be the default = 10
    task, // the async task
    10  // argument for the task
);

Unit Testing

$ npm test

Dependencies

  • get-log: a Node.js Logging Utility, easy to use and ready for production.

License

The project is released under the MIT license