lib/source-replacer.js
function getColumnAfter(lineIndex, columnIndex) {
    if (lineIndex in lines) {
      var line   = lines[lineIndex];
      var count  = 0;
      var offset = 0;
      for (var i = 0; i < line.length; i++) {
        var widthBefore = getBefore(line[i]).length;
        var widthAfter  = getAfter(line[i]).length;
        var nextCount   = count + widthBefore;
        if (nextCount > columnIndex) {
          break;
        } else {
          count   = nextCount;
          offset += widthAfter - widthBefore;
        }
      }
      return columnIndex + offset;
    } else {
      throw new Error('Line index is out of range');
    }
  }
function getColumnAfter(lineIndex, columnIndex) {
    if (lineIndex in lines) {
      var line   = lines[lineIndex];
      var count  = 0;
      var offset = 0;
      for (var i = 0; i < line.length; i++) {
        var widthBefore = getBefore(line[i]).length;
        var widthAfter  = getAfter(line[i]).length;
        var nextCount   = count + widthBefore;
        if (nextCount > columnIndex) {
          break;
        } else {
          count   = nextCount;
          offset += widthAfter - widthBefore;
        }
      }
      return columnIndex + offset;
    } else {
      throw new Error('Line index is out of range');
    }
  }
function getColumnAfter ( lineIndex , columnIndex ) { if ( lineIndex in lines ) { var line = lines [ lineIndex ] ; var count = 0 ; var offset = 0 ; for ( var i = 0 ; i < line . length ; i ++ ) { var widthBefore = getBefore ( line [ i ] ) . length ; var widthAfter = getAfter ( line [ i ] ) . length ; var nextCount = count + widthBefore ; if ( nextCount > columnIndex ) { break ; } else { count = nextCount ; offset += widthAfter - widthBefore ; } } return columnIndex + offset ; } else { throw new Error ( 'Line index is out of range' ) ; } }
Get a column position delta as at the given line and column that has occured as a result of replacement.
@param {number} lineIndex The line in the original source at which to evaluate the offset
@param {number} columnIndex The column in the original source at which to evaluate the offset
@returns {number} A column offset in characters
Get a column position delta as at the given line and column that has occured as a result of replacement .