UNPKG

@dipscope/type-manager

Version:

Transform JSON strings or plain objects into JS class instances.

108 lines 4.04 kB
var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var TypeScope = (function () { function TypeScope() { this.opened = false; this.propertyOptionsArrayMap = new Map(); this.injectOptionsArrayMap = new Map(); return; } TypeScope.prototype.open = function () { this.opened = true; this.propertyOptionsArrayMap.clear(); this.injectOptionsArrayMap.clear(); return this; }; TypeScope.prototype.addPropertyOptions = function (propertyName, propertyOptions) { if (!this.opened) { return this; } var propertyOptionsArray = this.propertyOptionsArrayMap.get(propertyName); if (propertyOptionsArray === undefined) { propertyOptionsArray = new Array(); this.propertyOptionsArrayMap.set(propertyName, propertyOptionsArray); } propertyOptionsArray.push(propertyOptions); return this; }; TypeScope.prototype.addInjectOptions = function (injectIndex, injectOptions) { if (!this.opened) { return this; } var injectOptionsArray = this.injectOptionsArrayMap.get(injectIndex); if (injectOptionsArray === undefined) { injectOptionsArray = new Array(); this.injectOptionsArrayMap.set(injectIndex, injectOptionsArray); } injectOptionsArray.push(injectOptions); return this; }; TypeScope.prototype.close = function (typeMetadata) { var e_1, _a, e_2, _b; if (!this.opened) { return this; } try { for (var _c = __values(this.propertyOptionsArrayMap), _d = _c.next(); !_d.done; _d = _c.next()) { var _e = __read(_d.value, 2), propertyName = _e[0], propertyOptionsArray = _e[1]; for (var i = 0; i < propertyOptionsArray.length; i++) { typeMetadata.configurePropertyMetadata(propertyName, propertyOptionsArray[i]); } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_1) throw e_1.error; } } try { for (var _f = __values(this.injectOptionsArrayMap), _g = _f.next(); !_g.done; _g = _f.next()) { var _h = __read(_g.value, 2), injectIndex = _h[0], injectOptionsArray = _h[1]; for (var i = 0; i < injectOptionsArray.length; i++) { typeMetadata.configureInjectMetadata(injectIndex, injectOptionsArray[i]); } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_g && !_g.done && (_b = _f.return)) _b.call(_f); } finally { if (e_2) throw e_2.error; } } this.injectOptionsArrayMap.clear(); this.propertyOptionsArrayMap.clear(); this.opened = false; return this; }; return TypeScope; }()); export { TypeScope }; //# sourceMappingURL=type-scope.js.map