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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
mojo / public / js / compile_preamble.js [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
/**
* @fileoverview Preamble for JavaScript to be compiled with Closure Compiler.
* We don't comple against the Closure library, so this provides a minimal set
* of 'goog' namespace properties to support things like symbol exports.
*
* @provideGoog
*/
/** @const */
var goog = {};
/** @const */
goog.global = this;
/**
* @param {string} name
* @param {*} object
* @param {Object=} opt_objectToExportTo
*/
goog.exportSymbol = function(name, object, opt_objectToExportTo) {
let parts = name.split('.');
let cur = opt_objectToExportTo || mojo.internal.globalScope;
for (let part; parts.length && (part = parts.shift());) {
if (!parts.length && object !== undefined)
cur[part] = object;
else if (cur[part] && cur[part] != Object.prototype[part])
cur = cur[part];
else
cur = cur[part] = {};
}
};
/**
* @param {Object} object
* @param {string} publicName
* @param {*} symbol
*/
goog.exportProperty = function(object, publicName, symbol) {
object[publicName] = symbol;
};
/**
* @param {string} name
*/
goog.provide = function(name) {
goog.exportSymbol(name, null, null);
};
/**
* @param {string} namespace
*/
goog.require = function(namespace) {};