/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { isPromiseLike } from "@fluidframework/core-utils/internal";
import { UsageError } from "@fluidframework/telemetry-utils/internal";
/**
 * @internal
 */
export class FluidDataStoreRegistry {
    get IFluidDataStoreRegistry() {
        return this;
    }
    constructor(namedEntries) {
        this.map = new Map();
        for (const entry of namedEntries) {
            if (this.map.has(entry[0])) {
                throw new UsageError("Duplicate entry names exist");
            }
            this.map.set(entry[0], entry[1]);
        }
    }
    async get(name) {
        if (this.map.has(name)) {
            return this.map.get(name);
        }
        return undefined;
    }
    getSync(name) {
        const entry = this.map.get(name);
        if (!isPromiseLike(entry)) {
            return entry;
        }
        return undefined;
    }
}
//# sourceMappingURL=dataStoreRegistry.js.map