UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

38 lines (37 loc) 1.57 kB
"use strict"; var __values = (this && this.__values)/* istanbul ignore next */ || function (o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; }; Object.defineProperty(exports, "__esModule", { value: true }); var ts = require("typescript"); var errors = require("./../errors"); function getRangeFromArray(array, index, length, expectedKind) { var children = array.slice(index, index + length); if (children.length !== length) throw new errors.NotImplementedError("Unexpected! Inserted " + length + " child/children, but " + children.length + " were inserted."); try { for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) { var child = children_1_1.value; if (child.getKind() !== expectedKind) throw new errors.NotImplementedError("Unexpected! Inserting syntax kind of " + ts.SyntaxKind[expectedKind] + (", but " + child.getKindName() + " was inserted.")); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1); } finally { if (e_1) throw e_1.error; } } return children; var e_1, _a; } exports.getRangeFromArray = getRangeFromArray;