release/rollbar-1.2.0.commonjs.js
function gatherContext(url, line) {
        var source = getSource(url);

        if (!source.length) {
            return null;
        }

        var context = [],
            // linesBefore & linesAfter are inclusive with the offending line.
            // if linesOfContext is even, there will be one extra line
            //   *before* the offending line.
            linesBefore = Math.floor(linesOfContext / 2),
            // Add one extra line if linesOfContext is odd
            linesAfter = linesBefore + (linesOfContext % 2),
            start = Math.max(0, line - linesBefore - 1),
            end = Math.min(source.length, line + linesAfter - 1);

        line -= 1; // convert to 0-based index

        for (var i = start; i < end; ++i) {
            if (!_isUndefined(source[i])) {
                context.push(source[i]);
            }
        }

        return context.length > 0 ? context : null;
    }
function gatherContext(url, line) {
        var source = getSource(url);

        if (!source.length) {
            return null;
        }

        var context = [],
            // linesBefore & linesAfter are inclusive with the offending line.
            // if linesOfContext is even, there will be one extra line
            //   *before* the offending line.
            linesBefore = Math.floor(linesOfContext / 2),
            // Add one extra line if linesOfContext is odd
            linesAfter = linesBefore + (linesOfContext % 2),
            start = Math.max(0, line - linesBefore - 1),
            end = Math.min(source.length, line + linesAfter - 1);

        line -= 1; // convert to 0-based index

        for (var i = start; i < end; ++i) {
            if (!_isUndefined(source[i])) {
                context.push(source[i]);
            }
        }

        return context.length > 0 ? context : null;
    }
function gatherContext ( url , line ) { var source = getSource ( url ) ; if ( ! source . length ) { return null ; } var context = [ ] , // linesBefore & linesAfter are inclusive with the offending line. // if linesOfContext is even, there will be one extra line //   *before* the offending line. linesBefore = Math . floor ( linesOfContext / 2 ) , // Add one extra line if linesOfContext is odd linesAfter = linesBefore + ( linesOfContext % 2 ) , start = Math . max ( 0 , line - linesBefore - 1 ) , end = Math . min ( source . length , line + linesAfter - 1 ) ; line -= 1 ; // convert to 0-based index for ( var i = start ; i < end ; ++ i ) { if ( ! _isUndefined ( source [ i ] ) ) { context . push ( source [ i ] ) ; } } return context . length > 0 ? context : null ; }
Retrieves the surrounding lines from where an exception occurred.
@param {string} url URL of source code.
@param {(string|number)} line Line number in source code to centre
around for context.
@return {?Array.<string>} Lines of source code.
Retrieves the surrounding lines from where an exception occurred .