UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for static analysis and code manipulation.

42 lines (41 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var errors = require("../../../errors"); var typescript_1 = require("../../../typescript"); var callBaseSet_1 = require("../callBaseSet"); var callBaseGetStructure_1 = require("../callBaseGetStructure"); function AsyncableNode(Base) { return /** @class */ (function (_super) { tslib_1.__extends(class_1, _super); function class_1() { return _super !== null && _super.apply(this, arguments) || this; } class_1.prototype.isAsync = function () { return this.hasModifier(typescript_1.SyntaxKind.AsyncKeyword); }; class_1.prototype.getAsyncKeyword = function () { return this.getFirstModifierByKind(typescript_1.SyntaxKind.AsyncKeyword); }; class_1.prototype.getAsyncKeywordOrThrow = function () { return errors.throwIfNullOrUndefined(this.getAsyncKeyword(), "Expected to find an async keyword."); }; class_1.prototype.setIsAsync = function (value) { this.toggleModifier("async", value); return this; }; class_1.prototype.set = function (structure) { callBaseSet_1.callBaseSet(Base.prototype, this, structure); if (structure.isAsync != null) this.setIsAsync(structure.isAsync); return this; }; class_1.prototype.getStructure = function () { return callBaseGetStructure_1.callBaseGetStructure(Base.prototype, this, { isAsync: this.isAsync() }); }; return class_1; }(Base)); } exports.AsyncableNode = AsyncableNode;