UNPKG

decaffeinate-parser

Version:

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

24 lines (23 loc) 780 B
"use strict"; exports.__esModule = true; 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 }; } exports["default"] = sourceRangeFromLocationData;