123456789101112131415161718192021222324252627282930313233343536373839 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- const _symbols = [];
- const __internalMark__ = {};
- class HiddenSymbol {
- constructor(target) {
- Object.defineProperties(this, {
- target: {
- enumerable: false,
- writable: false,
- configurable: false,
- value: target,
- },
- });
- }
- }
- class InternalSymbol extends HiddenSymbol {
- constructor(target, __mark__) {
- if (__mark__ !== __internalMark__) {
- throw new TypeError('InternalSymbol cannot be constructed with new operator');
- }
- super(target);
- }
- static for(target) {
- for (let i = 0, len = _symbols.length; i < len; i++) {
- if (_symbols[i].target === target) {
- return _symbols[i].instance;
- }
- }
- const symbol = new InternalSymbol(target, __internalMark__);
- _symbols.push({
- target,
- instance: symbol,
- });
- return symbol;
- }
- }
- exports.InternalSymbol = InternalSymbol;
- exports.default = InternalSymbol;
|