1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27

mojo / public / js / mojo_internal_preamble.js.part [blame]

'use strict';

goog.provide('mojo.internal');

// "self" is always defined as opposed to "this", which isn't defined in
// modules, or "window", which isn't defined in workers.
/** @const {!Object} */
mojo.internal.globalScope = self;

/**
 * This is effectively the same as goog.provide, but it's made available under
 * the mojo.internal namespace to avoid potential collisions in certain
 * compilation environments.
 *
 * @param {string} namespace
 * @export
 */
mojo.internal.exportModule = function(namespace) {
  let current = mojo.internal.globalScope;
  const parts = namespace.split('.');

  for (let part; parts.length && (part = parts.shift());) {
    if (!current[part])
      current[part] = {};
    current = current[part];
  }
};