merge.js 494 B

12345678910111213141516171819202122232425262728
  1. 'use strict'
  2. var xtend = require('xtend')
  3. var Schema = require('./schema')
  4. module.exports = merge
  5. function merge(definitions) {
  6. var length = definitions.length
  7. var property = []
  8. var normal = []
  9. var index = -1
  10. var info
  11. var space
  12. while (++index < length) {
  13. info = definitions[index]
  14. property.push(info.property)
  15. normal.push(info.normal)
  16. space = info.space
  17. }
  18. return new Schema(
  19. xtend.apply(null, property),
  20. xtend.apply(null, normal),
  21. space
  22. )
  23. }