lib/checks.js
function (callback) {
            async.until(
                // conditions for stopping the poll
                function () {
                    waitTimeOver = elapsed > constants.WAIT_TIMEOUT;
                    return waitTimeOver || domHasChanged;
                },
                function (callback) {
                    // polls the page at an interval
                    setTimeout(function () {
                        elapsed += constants.POLL_INTERVAL;
                        getData.takeSnapshot(page, ph, function (error, page, ph, newDom) {
                            if (error) {
                                callback(error);
                                return;
                            }
                            domHasChanged = helpers.domIsDifferent(originalDom, newDom);
                            callback();
                        });
                    }, constants.POLL_INTERVAL);
                },

                function (error) {
                    if (waitTimeOver) {
                        callback('Timeout while waiting for dom to change');
                        return;
                    }
                    callback(error);
                }
            );
        }
function (callback) {
            async.until(
                // conditions for stopping the poll
                function () {
                    waitTimeOver = elapsed > constants.WAIT_TIMEOUT;
                    return waitTimeOver || domHasChanged;
                },
                function (callback) {
                    // polls the page at an interval
                    setTimeout(function () {
                        elapsed += constants.POLL_INTERVAL;
                        getData.takeSnapshot(page, ph, function (error, page, ph, newDom) {
                            if (error) {
                                callback(error);
                                return;
                            }
                            domHasChanged = helpers.domIsDifferent(originalDom, newDom);
                            callback();
                        });
                    }, constants.POLL_INTERVAL);
                },

                function (error) {
                    if (waitTimeOver) {
                        callback('Timeout while waiting for dom to change');
                        return;
                    }
                    callback(error);
                }
            );
        }
function ( callback ) { async . until ( // conditions for stopping the poll function ( ) { waitTimeOver = elapsed > constants . WAIT_TIMEOUT ; return waitTimeOver || domHasChanged ; } , function ( callback ) { // polls the page at an interval setTimeout ( function ( ) { elapsed += constants . POLL_INTERVAL ; getData . takeSnapshot ( page , ph , function ( error , page , ph , newDom ) { if ( error ) { callback ( error ) ; return ; } domHasChanged = helpers . domIsDifferent ( originalDom , newDom ) ; callback ( ) ; } ) ; } , constants . POLL_INTERVAL ) ; } , function ( error ) { if ( waitTimeOver ) { callback ( 'Timeout while waiting for dom to change' ) ; return ; } callback ( error ) ; } ) ; }
poll the page for changes in the dom or until timeout
poll the page for changes in the dom or until timeout