combine-html-extensions.js 670 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict'
  2. var hasOwnProperty = require('../constant/has-own-property.js')
  3. // Combine several HTML extensions into one.
  4. function combineHtmlExtensions(extensions) {
  5. var handlers = {}
  6. var index = -1
  7. while (++index < extensions.length) {
  8. extension(handlers, extensions[index])
  9. }
  10. return handlers
  11. }
  12. function extension(handlers, extension) {
  13. var hook
  14. var left
  15. var right
  16. var type
  17. for (hook in extension) {
  18. left = hasOwnProperty.call(handlers, hook)
  19. ? handlers[hook]
  20. : (handlers[hook] = {})
  21. right = extension[hook]
  22. for (type in right) {
  23. left[type] = right[type]
  24. }
  25. }
  26. }
  27. module.exports = combineHtmlExtensions