UNPKG

decaffeinate-parser

Version:

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

21 lines (20 loc) 843 B
"use strict"; /* eslint-disable @typescript-eslint/camelcase */ exports.__esModule = true; function locationDataFromSourceRange(context, sourceRange) { var startLocationInclusive = context.linesAndColumns.locationForIndex(sourceRange.start); if (startLocationInclusive === null) { throw new Error('Expected start location for source range.'); } var endLocationInclusive = context.linesAndColumns.locationForIndex(sourceRange.end - 1); if (endLocationInclusive === null) { throw new Error('Expected end location for source range.'); } return { first_line: startLocationInclusive.line, first_column: startLocationInclusive.column, last_line: endLocationInclusive.line, last_column: endLocationInclusive.column }; } exports["default"] = locationDataFromSourceRange;