| '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]; |
| } |
| }; |