src/modules/rangy-textrange.js
function consumeWord(forward) {
            log.debug("consumeWord called, forward is " + forward);
            var pos, textChar;
            var newChars = [], it = forward ? forwardIterator : backwardIterator;

            var passedWordBoundary = false, insideWord = false;

            while ( (pos = it.next()) ) {
                textChar = pos.character;

                log.debug("Testing char '" + textChar + "'");

                if (allWhiteSpaceRegex.test(textChar)) {
                    if (insideWord) {
                        insideWord = false;
                        passedWordBoundary = true;
                    }
                } else {
                    log.debug("Got non-whitespace, passedWordBoundary is " + passedWordBoundary);
                    if (passedWordBoundary) {
                        it.rewind();
                        break;
                    } else {
                        insideWord = true;
                    }
                }
                newChars.push(pos);
            }

            log.debug("consumeWord done, pos is " + (pos ? pos.inspect() : "non-existent"));

            log.debug("consumeWord got new chars " + newChars.join(""));
            return newChars;
        }
function consumeWord(forward) {
            log.debug("consumeWord called, forward is " + forward);
            var pos, textChar;
            var newChars = [], it = forward ? forwardIterator : backwardIterator;

            var passedWordBoundary = false, insideWord = false;

            while ( (pos = it.next()) ) {
                textChar = pos.character;

                log.debug("Testing char '" + textChar + "'");

                if (allWhiteSpaceRegex.test(textChar)) {
                    if (insideWord) {
                        insideWord = false;
                        passedWordBoundary = true;
                    }
                } else {
                    log.debug("Got non-whitespace, passedWordBoundary is " + passedWordBoundary);
                    if (passedWordBoundary) {
                        it.rewind();
                        break;
                    } else {
                        insideWord = true;
                    }
                }
                newChars.push(pos);
            }

            log.debug("consumeWord done, pos is " + (pos ? pos.inspect() : "non-existent"));

            log.debug("consumeWord got new chars " + newChars.join(""));
            return newChars;
        }
function consumeWord ( forward ) { log . debug ( "consumeWord called, forward is " + forward ) ; var pos , textChar ; var newChars = [ ] , it = forward ? forwardIterator : backwardIterator ; var passedWordBoundary = false , insideWord = false ; while ( ( pos = it . next ( ) ) ) { textChar = pos . character ; log . debug ( "Testing char '" + textChar + "'" ) ; if ( allWhiteSpaceRegex . test ( textChar ) ) { if ( insideWord ) { insideWord = false ; passedWordBoundary = true ; } } else { log . debug ( "Got non-whitespace, passedWordBoundary is " + passedWordBoundary ) ; if ( passedWordBoundary ) { it . rewind ( ) ; break ; } else { insideWord = true ; } } newChars . push ( pos ) ; } log . debug ( "consumeWord done, pos is " + ( pos ? pos . inspect ( ) : "non-existent" ) ) ; log . debug ( "consumeWord got new chars " + newChars . join ( "" ) ) ; return newChars ; }
Consumes a word and the whitespace beyond it
Consumes a word and the whitespace beyond it