decaffeinate-parser
Version:
A better AST for CoffeeScript, inspired by CoffeeScriptRedux.
12 lines (11 loc) • 565 B
JavaScript
import { inspect } from 'util';
import { Range } from '../nodes';
import getLocation from '../util/getLocation';
import mapAny from './mapAny';
export default function mapRange(context, node) {
var _a = getLocation(context, node), line = _a.line, column = _a.column, start = _a.start, end = _a.end, raw = _a.raw;
if (!node.from || !node.to) {
throw new Error("'from' or 'to' unexpectedly missing: " + inspect(node));
}
return new Range(line, column, start, end, raw, mapAny(context, node.from), mapAny(context, node.to), !node.exclusive);
}