UNPKG

@k8ts/instruments

Version:

A collection of utilities and core components for k8ts.

41 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Embedder = void 0; class Embedder { name; _symbol; constructor(name) { this.name = name; this._symbol = Symbol.for(`build.k8ts.org/${name}`); } [Symbol.toStringTag]() { return `Embedder(${this.name})`; } toString() { return this[Symbol.toStringTag](); } set(target, data) { if (Object.prototype.hasOwnProperty.call(target, this._symbol)) { throw new Error(`Decorator ${this.name} already set!`); } Object.defineProperty(target, this._symbol, { enumerable: true, value: data, writable: true, configurable: true }); return this; } tryGet(target) { return Reflect.get(target, this._symbol); } get(target) { const input = this.tryGet(target); if (!input) { throw new Error(`Target of type ${target} doesn't have any embedded data for ${this.name}!`); } return input; } } exports.Embedder = Embedder; //# sourceMappingURL=base.js.map