Sha256: 620259802e439bec4bbe6bb6e4e424e3eedb90e05289cea3b3f358fedf58cf90

Contents?: true

Size: 811 Bytes

Versions: 7

Compression:

Stored size: 811 Bytes

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getLineInfo = getLineInfo;
exports.SourceLocation = exports.Position = void 0;

var _whitespace = require("./whitespace");

class Position {
  constructor(line, col) {
    this.line = line;
    this.column = col;
  }

}

exports.Position = Position;

class SourceLocation {
  constructor(start, end) {
    this.start = start;
    this.end = end;
  }

}

exports.SourceLocation = SourceLocation;

function getLineInfo(input, offset) {
  let line = 1;
  let lineStart = 0;
  let match;
  _whitespace.lineBreakG.lastIndex = 0;

  while ((match = _whitespace.lineBreakG.exec(input)) && match.index < offset) {
    line++;
    lineStart = _whitespace.lineBreakG.lastIndex;
  }

  return new Position(line, offset - lineStart);
}

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
enju_library-0.3.8 spec/dummy/node_modules/@babel/parser/lib/util/location.js
condenser-0.2 lib/condenser/processors/node_modules/@babel/parser/lib/util/location.js
condenser-0.1 lib/condenser/processors/node_modules/@babel/parser/lib/util/location.js
condenser-0.0.12 lib/condenser/processors/node_modules/@babel/parser/lib/util/location.js
condenser-0.0.11 lib/condenser/processors/node_modules/@babel/parser/lib/util/location.js
condenser-0.0.10 lib/condenser/processors/node_modules/@babel/parser/lib/util/location.js
condenser-0.0.9 lib/condenser/processors/node_modules/@babel/parser/lib/util/location.js