src/LiveDevelopment/Agents/DOMHelpers.js
function eachNode(src, callback) {
        var index = 0;
        var text, range, length, payload;
        while (index < src.length) {

            // find the next tag
            range = _findTag(src, index);
            if (!range) {
                range = { from: src.length, length: 0 };
            }

            // add the text before the tag
            length = range.from - index;
            if (length > 0) {
                text = src.substr(index, length);
                if (/\S/.test(text)) {
                    payload = extractPayload(text);
                    payload.sourceOffset = index;
                    payload.sourceLength = length;
                    callback(payload);
                }
            }

            // add the tag
            if (range.length > 0) {
                payload = extractPayload(src.substr(range.from, range.length));
                payload.sourceOffset = range.from;
                payload.sourceLength = range.length;
                callback(payload);
            }

            // advance
            index = range.from + range.length;
        }
    }
function eachNode(src, callback) {
        var index = 0;
        var text, range, length, payload;
        while (index < src.length) {

            // find the next tag
            range = _findTag(src, index);
            if (!range) {
                range = { from: src.length, length: 0 };
            }

            // add the text before the tag
            length = range.from - index;
            if (length > 0) {
                text = src.substr(index, length);
                if (/\S/.test(text)) {
                    payload = extractPayload(text);
                    payload.sourceOffset = index;
                    payload.sourceLength = length;
                    callback(payload);
                }
            }

            // add the tag
            if (range.length > 0) {
                payload = extractPayload(src.substr(range.from, range.length));
                payload.sourceOffset = range.from;
                payload.sourceLength = range.length;
                callback(payload);
            }

            // advance
            index = range.from + range.length;
        }
    }
function eachNode ( src , callback ) { var index = 0 ; var text , range , length , payload ; while ( index < src . length ) { // find the next tag range = _findTag ( src , index ) ; if ( ! range ) { range = { from : src . length , length : 0 } ; } // add the text before the tag length = range . from - index ; if ( length > 0 ) { text = src . substr ( index , length ) ; if ( / \S / . test ( text ) ) { payload = extractPayload ( text ) ; payload . sourceOffset = index ; payload . sourceLength = length ; callback ( payload ) ; } } // add the tag if ( range . length > 0 ) { payload = extractPayload ( src . substr ( range . from , range . length ) ) ; payload . sourceOffset = range . from ; payload . sourceLength = range . length ; callback ( payload ) ; } // advance index = range . from + range . length ; } }
Split the source string into payloads representing individual nodes
@param {string} source
@param {function(payload)} callback
 split a string into individual node contents
Split the source string into payloads representing individual nodes