UNPKG

decaffeinate-parser

Version:

A better AST for CoffeeScript, inspired by CoffeeScriptRedux.

13 lines (12 loc) 770 B
import mapAny from '../mappers/mapAny'; import * as nodes from '../nodes'; import getTemplateLiteralComponents from './getTemplateLiteralComponents'; export default function makeString(context, node) { var _a = getTemplateLiteralComponents(context, node), quasis = _a.quasis, unmappedExpressions = _a.unmappedExpressions, start = _a.start, end = _a.end; var startLoc = context.linesAndColumns.locationForIndex(start); if (!startLoc) { throw new Error("Expected to find a location for index " + start + "."); } var raw = context.source.slice(start, end); return new nodes.String(startLoc.line + 1, startLoc.column + 1, start, end, raw, quasis, unmappedExpressions.map(function (expr) { return (expr ? mapAny(context, expr) : null); })); }