merge.js 607 B

123456789101112131415161718192021222324252627
  1. /**
  2. * @import {Info, Space} from 'property-information'
  3. */
  4. import {Schema} from './schema.js'
  5. /**
  6. * @param {ReadonlyArray<Schema>} definitions
  7. * Definitions.
  8. * @param {Space | undefined} [space]
  9. * Space.
  10. * @returns {Schema}
  11. * Schema.
  12. */
  13. export function merge(definitions, space) {
  14. /** @type {Record<string, Info>} */
  15. const property = {}
  16. /** @type {Record<string, string>} */
  17. const normal = {}
  18. for (const definition of definitions) {
  19. Object.assign(property, definition.property)
  20. Object.assign(normal, definition.normal)
  21. }
  22. return new Schema(property, normal, space)
  23. }