UNPKG

@dipscope/type-manager

Version:

Transform JSON strings or plain objects into JS class instances.

99 lines 4.33 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { EMPTY_ARRAY } from './constants/empty-array'; import { getOwnReflectMetadata } from './functions/get-own-reflect-metadata'; import { ResolvedInjectState } from './inject-states/resolved-inject-state'; import { UnresolvedInjectState } from './inject-states/unresolved-inject-state'; import { Metadata } from './metadata'; var InjectMetadata = (function (_super) { __extends(InjectMetadata, _super); function InjectMetadata(typeManager, typeFnMap, declaringTypeMetadata, injectIndex, injectOptions) { var _this = this; var _a; _this = _super.call(this, typeManager, typeFnMap) || this; _this.declaringTypeMetadata = declaringTypeMetadata; _this.injectIndex = injectIndex; _this.injectOptions = injectOptions; _this.reflectTypeFn = ((_a = getOwnReflectMetadata('design:paramtypes', declaringTypeMetadata.typeFn)) !== null && _a !== void 0 ? _a : EMPTY_ARRAY)[injectIndex]; _this.currentInjectState = new UnresolvedInjectState(_this); _this.configure(injectOptions); return _this; } Object.defineProperty(InjectMetadata.prototype, "injectState", { get: function () { return this.currentInjectState; }, enumerable: false, configurable: true }); Object.defineProperty(InjectMetadata.prototype, "key", { get: function () { return this.currentInjectState.key; }, enumerable: false, configurable: true }); Object.defineProperty(InjectMetadata.prototype, "typeArgument", { get: function () { return this.currentInjectState.typeArgument; }, enumerable: false, configurable: true }); Object.defineProperty(InjectMetadata.prototype, "typeMetadata", { get: function () { return this.currentInjectState.typeMetadata; }, enumerable: false, configurable: true }); InjectMetadata.prototype.resolveInjectState = function () { var injectOptions = this.injectOptions; var key = injectOptions.key; var typeArgument = injectOptions.typeArgument === undefined ? this.reflectTypeFn : injectOptions.typeArgument; var typeMetadata = this.resolveTypeMetadata(typeArgument); var resolvedInjectState = new ResolvedInjectState(this, key, typeArgument, typeMetadata); this.currentInjectState = resolvedInjectState; return resolvedInjectState; }; InjectMetadata.prototype.unresolveInjectState = function () { var unresolvedInjectState = new UnresolvedInjectState(this); this.currentInjectState = unresolvedInjectState; return unresolvedInjectState; }; InjectMetadata.prototype.hasKey = function (key) { this.injectOptions.key = key; this.currentInjectState = new UnresolvedInjectState(this); return this; }; InjectMetadata.prototype.hasTypeArgument = function (typeArgument) { this.injectOptions.typeArgument = typeArgument; this.currentInjectState = new UnresolvedInjectState(this); return this; }; InjectMetadata.prototype.configure = function (injectOptions) { if (injectOptions.key !== undefined) { this.hasKey(injectOptions.key); } if (injectOptions.typeArgument !== undefined) { this.hasTypeArgument(injectOptions.typeArgument); } return this; }; return InjectMetadata; }(Metadata)); export { InjectMetadata }; //# sourceMappingURL=inject-metadata.js.map