Clumpy: Non-Blocking Loops in JavaScript

Clumpy (formerly Asynchronizer) provides a way of modeling incremental asynchronous processes after traditional loops, letting you focus on your program without having to manage the code that chops it up.

clumpy.for_loop(
    function () { i = 0; },
    function () { return i < 100000; },
    function () { i++; },
    function () {
        // statements
    }
);

Features

Clumpy emulates for, for...in, while, do...while, continue, and break. These can be labeled, nested, chained, and interspersed with non-loop operations. Execution can be paused and resumed in various ways.

It creates a managed chain of timeouts, promising to perform all the iterations in the proper order. The number of iterations performed in each single “clump” of execution is adjusted transparently to suit the speed of the computer executing the code.

Usage

Continue on to the usage guide for a quick tutorial.

Download

Get Clumpy.

Reference

Read the official specs.

Version History

2013-04-14 (current version)
Changed interface to address design flaw.
2012-10-31
Fixed bug reported by Vas Gábor.
2009-10-24
Added init, interrupt and setNow methods.
2009-03-01
Fixed a bug that prevented a Clumpy instance from being re-used.
2009-01-12
First version as Clumpy.
© Thomas Peri