Front end of the Slack clone application.

index.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*!
  2. * merge-descriptors
  3. * Copyright(c) 2014 Jonathan Ong
  4. * Copyright(c) 2015 Douglas Christopher Wilson
  5. * MIT Licensed
  6. */
  7. 'use strict'
  8. /**
  9. * Module exports.
  10. * @public
  11. */
  12. module.exports = merge
  13. /**
  14. * Module variables.
  15. * @private
  16. */
  17. var hasOwnProperty = Object.prototype.hasOwnProperty
  18. /**
  19. * Merge the property descriptors of `src` into `dest`
  20. *
  21. * @param {object} dest Object to add descriptors to
  22. * @param {object} src Object to clone descriptors from
  23. * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
  24. * @returns {object} Reference to dest
  25. * @public
  26. */
  27. function merge(dest, src, redefine) {
  28. if (!dest) {
  29. throw new TypeError('argument dest is required')
  30. }
  31. if (!src) {
  32. throw new TypeError('argument src is required')
  33. }
  34. if (redefine === undefined) {
  35. // Default to true
  36. redefine = true
  37. }
  38. Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
  39. if (!redefine && hasOwnProperty.call(dest, name)) {
  40. // Skip desriptor
  41. return
  42. }
  43. // Copy descriptor
  44. var descriptor = Object.getOwnPropertyDescriptor(src, name)
  45. Object.defineProperty(dest, name, descriptor)
  46. })
  47. return dest
  48. }