You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

helpers.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // @flow
  2. /**
  3. * Returns the namespace for all global variables, functions, etc that we need.
  4. *
  5. * @returns {Object} The namespace.
  6. *
  7. * NOTE: After React-ifying everything this should be the only global.
  8. */
  9. export function getJitsiMeetGlobalNS() {
  10. if (!window.JitsiMeetJS) {
  11. window.JitsiMeetJS = {};
  12. }
  13. if (!window.JitsiMeetJS.app) {
  14. window.JitsiMeetJS.app = {};
  15. }
  16. return window.JitsiMeetJS.app;
  17. }
  18. /**
  19. * A helper function that behaves similar to Object.assign, but only reassigns a
  20. * property in target if it's defined in source.
  21. *
  22. * @param {Object} target - The target object to assign the values into.
  23. * @param {Object} source - The source object.
  24. * @returns {Object}
  25. */
  26. export function assignIfDefined(target: Object, source: Object) {
  27. const to = Object(target);
  28. for (const nextKey in source) {
  29. if (source.hasOwnProperty(nextKey)) {
  30. const value = source[nextKey];
  31. if (typeof value !== 'undefined') {
  32. to[nextKey] = value;
  33. }
  34. }
  35. }
  36. return to;
  37. }