UNPKG

@apollo/core-schema

Version:
60 lines 2.68 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _ScopeMap_entries; Object.defineProperty(exports, "__esModule", { value: true }); exports.ScopeMap = void 0; class ScopeMap { constructor(parent, entries = new Map()) { this.parent = parent; _ScopeMap_entries.set(this, void 0); __classPrivateFieldSet(this, _ScopeMap_entries, entries, "f"); } own(key) { return __classPrivateFieldGet(this, _ScopeMap_entries, "f").get(key); } has(key) { var _a; return this.hasOwn(key) || !!((_a = this.parent) === null || _a === void 0 ? void 0 : _a.has(key)); } hasOwn(key) { return __classPrivateFieldGet(this, _ScopeMap_entries, "f").has(key); } lookup(key) { var _a, _b; return (_a = this.own(key)) !== null && _a !== void 0 ? _a : (_b = this.parent) === null || _b === void 0 ? void 0 : _b.lookup(key); } entries() { return __classPrivateFieldGet(this, _ScopeMap_entries, "f").entries(); } *visible() { const seen = new Set(); for (const ent of this.entries()) { seen.add(ent[0]); yield ent; } if (this.parent) for (const ent of this.parent.visible()) { if (seen.has(ent[0])) continue; seen.add(ent[0]); yield ent; } } set(key, value) { __classPrivateFieldGet(this, _ScopeMap_entries, "f").set(key, value); } } exports.ScopeMap = ScopeMap; _ScopeMap_entries = new WeakMap(); exports.default = ScopeMap; //# sourceMappingURL=scope-map.js.map