UNPKG

structured-elements

Version:

A TypeScript package for modelling and validating data

18 lines 770 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addElementToMirror = void 0; const build_1 = require("./build"); const addElementToMirror = ({ element, mirror, options, }) => { const key = (options === null || options === void 0 ? void 0 : options.extractKey) ? options.extractKey(element) : element.id; if (!key) { throw new Error(`addElementToMirror failed: element must have an id or options must provide an extractKey function. Called with: ${JSON.stringify({ element, mirror, options })}`); } return (0, build_1.buildMirror)({ ...mirror.collection, [key]: element, }, options); }; exports.addElementToMirror = addElementToMirror; //# sourceMappingURL=addElement.js.map