UNPKG

typescript-domain

Version:

Decorator-based transformation of JSON or plain Javascript objects to classes

21 lines (20 loc) 754 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultMetadataStorage = void 0; class MetadataStorage { static _instance; // eslint-disable-next-line @typescript-eslint/ban-types metadata = new Map(); static get Instance() { return this._instance || (this._instance = new this()); } // eslint-disable-next-line @typescript-eslint/ban-types getMetadata(target) { return this.metadata.get(target); } addMetadata(metadata) { const currentMetadata = this.metadata.get(metadata.target); this.metadata.set(metadata.target, currentMetadata ? [...currentMetadata, metadata] : [metadata]); } } exports.defaultMetadataStorage = MetadataStorage.Instance;