UNPKG

decaffeinate-parser

Version:

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

21 lines (20 loc) 704 B
export default function sourceRangeFromLocationData(context, locationData) { var startIndexInclusive = context.linesAndColumns.indexForLocation({ line: locationData.first_line, column: locationData.first_column }); if (startIndexInclusive === null) { throw new Error('Expected index for start of range.'); } var endIndexInclusive = context.linesAndColumns.indexForLocation({ line: locationData.last_line, column: locationData.last_column }); if (endIndexInclusive === null) { throw new Error('Expected index for end of range.'); } return { start: startIndexInclusive, end: endIndexInclusive + 1 }; }