UNPKG

decaffeinate-parser

Version:

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

18 lines (17 loc) 767 B
/* eslint-disable @typescript-eslint/camelcase */ export default 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 }; }