lib/tokenizer/Tokenizer.js
function computeLinesAndColumns(tokenizer, source) {
    var sourceLength = source.length;
    var start = firstCharOffset(source);
    var lines = tokenizer.lines;
    var line = tokenizer.startLine;
    var columns = tokenizer.columns;
    var column = tokenizer.startColumn;

    if (lines === null || lines.length < sourceLength + 1) {
        lines = new SafeUint32Array(Math.max(sourceLength + 1024, MIN_BUFFER_SIZE));
        columns = new SafeUint32Array(lines.length);
    }

    for (var i = start; i < sourceLength; i++) {
        var code = source.charCodeAt(i);

        lines[i] = line;
        columns[i] = column++;

        if (code === N || code === R || code === F) {
            if (code === R && i + 1 < sourceLength && source.charCodeAt(i + 1) === N) {
                i++;
                lines[i] = line;
                columns[i] = column;
            }

            line++;
            column = 1;
        }
    }

    lines[i] = line;
    columns[i] = column;

    tokenizer.linesAnsColumnsComputed = true;
    tokenizer.lines = lines;
    tokenizer.columns = columns;
}
function computeLinesAndColumns(tokenizer, source) {
    var sourceLength = source.length;
    var start = firstCharOffset(source);
    var lines = tokenizer.lines;
    var line = tokenizer.startLine;
    var columns = tokenizer.columns;
    var column = tokenizer.startColumn;

    if (lines === null || lines.length < sourceLength + 1) {
        lines = new SafeUint32Array(Math.max(sourceLength + 1024, MIN_BUFFER_SIZE));
        columns = new SafeUint32Array(lines.length);
    }

    for (var i = start; i < sourceLength; i++) {
        var code = source.charCodeAt(i);

        lines[i] = line;
        columns[i] = column++;

        if (code === N || code === R || code === F) {
            if (code === R && i + 1 < sourceLength && source.charCodeAt(i + 1) === N) {
                i++;
                lines[i] = line;
                columns[i] = column;
            }

            line++;
            column = 1;
        }
    }

    lines[i] = line;
    columns[i] = column;

    tokenizer.linesAnsColumnsComputed = true;
    tokenizer.lines = lines;
    tokenizer.columns = columns;
}
function computeLinesAndColumns ( tokenizer , source ) { var sourceLength = source . length ; var start = firstCharOffset ( source ) ; var lines = tokenizer . lines ; var line = tokenizer . startLine ; var columns = tokenizer . columns ; var column = tokenizer . startColumn ; if ( lines === null || lines . length < sourceLength + 1 ) { lines = new SafeUint32Array ( Math . max ( sourceLength + 1024 , MIN_BUFFER_SIZE ) ) ; columns = new SafeUint32Array ( lines . length ) ; } for ( var i = start ; i < sourceLength ; i ++ ) { var code = source . charCodeAt ( i ) ; lines [ i ] = line ; columns [ i ] = column ++ ; if ( code === N || code === R || code === F ) { if ( code === R && i + 1 < sourceLength && source . charCodeAt ( i + 1 ) === N ) { i ++ ; lines [ i ] = line ; columns [ i ] = column ; } line ++ ; column = 1 ; } } lines [ i ] = line ; columns [ i ] = column ; tokenizer . linesAnsColumnsComputed = true ; tokenizer . lines = lines ; tokenizer . columns = columns ; }
fallback on Array when TypedArray is not supported
fallback on Array when TypedArray is not supported