/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { assert } from "@fluidframework/common-utils";
import { treeSchema, } from "../core";
import { emptyField } from "./defaultSchema";
/**
 * Helper for building {@link NamedTreeSchema}.
 * @alpha
 */
export function namedTreeSchema(data) {
    return Object.assign({ name: data.name }, treeSchema(Object.assign({ extraLocalFields: emptyField }, data)));
}
/**
 * @returns a map from name of item with that name from a collection of named items.
 */
export function mapFromNamed(named) {
    const map = new Map();
    for (const item of named) {
        assert(!map.has(item.name), 0x4bb /* cannot build map from named items with colliding names. */);
        map.set(item.name, item);
    }
    return map;
}
//# sourceMappingURL=viewSchemaUtil.js.map