UNPKG

@adpt/cloud

Version:
38 lines 1.41 kB
"use strict"; /* * Copyright 2018 Unbounded Systems, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); class TypeResolver { constructor(resolveType) { this.resolveType = resolveType; this.resolvedTypes = new Map(); this.addType = (tyName, ty) => { if (this.resolvedTypes.has(tyName)) throw new Error(`Attempt to add duplicate type '{$tyName}'`); this.resolvedTypes.set(tyName, ty); }; this.getType = (tyName) => { const ty = this.resolvedTypes.get(tyName); if (ty !== undefined) return ty; const newTy = this.resolveType(tyName); this.addType(tyName, newTy); return newTy; }; } } exports.TypeResolver = TypeResolver; //# sourceMappingURL=type_resolver.js.map