mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Rename window to root.
This commit is contained in:
46
perf/perf.js
46
perf/perf.js
@@ -1,16 +1,16 @@
|
|||||||
(function(window) {
|
;(function(root) {
|
||||||
|
|
||||||
/** Use a single "load" function */
|
/** Use a single "load" function */
|
||||||
var load = typeof require == 'function' ? require : window.load;
|
var load = typeof require == 'function' ? require : root.load;
|
||||||
|
|
||||||
/** The file path of the Lo-Dash file to test */
|
/** The file path of the Lo-Dash file to test */
|
||||||
var filePath = (function() {
|
var filePath = (function() {
|
||||||
var min = 0;
|
var min = 0;
|
||||||
var result = window.phantom
|
var result = root.phantom
|
||||||
? phantom.args
|
? phantom.args
|
||||||
: (window.system
|
: (root.system
|
||||||
? (min = 1, system.args)
|
? (min = 1, system.args)
|
||||||
: (window.process ? (min = 2, process.argv) : (window.arguments || []))
|
: (root.process ? (min = 2, process.argv) : (root.arguments || []))
|
||||||
);
|
);
|
||||||
|
|
||||||
var last = result[result.length - 1];
|
var last = result[result.length - 1];
|
||||||
@@ -26,22 +26,22 @@
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
/** Load Lo-Dash */
|
/** Load Lo-Dash */
|
||||||
var lodash = window.lodash || (window.lodash = (
|
var lodash = root.lodash || (root.lodash = (
|
||||||
lodash = load(filePath) || window._,
|
lodash = load(filePath) || root._,
|
||||||
lodash = lodash._ || lodash,
|
lodash = lodash._ || lodash,
|
||||||
lodash.noConflict()
|
lodash.noConflict()
|
||||||
));
|
));
|
||||||
|
|
||||||
/** Load Benchmark.js */
|
/** Load Benchmark.js */
|
||||||
var Benchmark = window.Benchmark || (window.Benchmark = (
|
var Benchmark = root.Benchmark || (root.Benchmark = (
|
||||||
Benchmark = load('../vendor/benchmark.js/benchmark.js') || window.Benchmark,
|
Benchmark = load('../vendor/benchmark.js/benchmark.js') || root.Benchmark,
|
||||||
Benchmark = Benchmark.Benchmark || Benchmark,
|
Benchmark = Benchmark.Benchmark || Benchmark,
|
||||||
Benchmark.runInContext(lodash.extend({}, window, { '_': lodash }))
|
Benchmark.runInContext(lodash.extend({}, root, { '_': lodash }))
|
||||||
));
|
));
|
||||||
|
|
||||||
/** Load Underscore */
|
/** Load Underscore */
|
||||||
var _ = window._ || (window._ = (
|
var _ = root._ || (root._ = (
|
||||||
_ = load('../vendor/underscore/underscore.js') || window._,
|
_ = load('../vendor/underscore/underscore.js') || root._,
|
||||||
_._ || _
|
_._ || _
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -67,28 +67,28 @@
|
|||||||
var toString = Object.prototype.toString;
|
var toString = Object.prototype.toString;
|
||||||
|
|
||||||
/** The `ui` object */
|
/** The `ui` object */
|
||||||
var ui = window.ui || (window.ui = {
|
var ui = root.ui || (root.ui = {
|
||||||
'buildPath': basename(filePath, '.js'),
|
'buildPath': basename(filePath, '.js'),
|
||||||
'otherPath': 'underscore'
|
'otherPath': 'underscore'
|
||||||
});
|
});
|
||||||
|
|
||||||
/** The Lo-Dash build basename */
|
/** The Lo-Dash build basename */
|
||||||
var buildName = window.buildName = basename(ui.buildPath, '.js');
|
var buildName = root.buildName = basename(ui.buildPath, '.js');
|
||||||
|
|
||||||
/** The other library basename */
|
/** The other library basename */
|
||||||
var otherName = window.otherName = (function() {
|
var otherName = root.otherName = (function() {
|
||||||
var result = basename(ui.otherPath, '.js');
|
var result = basename(ui.otherPath, '.js');
|
||||||
return result + (result == buildName ? ' (2)' : '');
|
return result + (result == buildName ? ' (2)' : '');
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/** Detect if in a browser environment */
|
/** Detect if in a browser environment */
|
||||||
var isBrowser = isHostType(window, 'document') && isHostType(window, 'navigator');
|
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
|
||||||
|
|
||||||
/** Detect Java environment */
|
/** Detect Java environment */
|
||||||
var isJava = !isBrowser && /Java/.test(toString.call(window.java));
|
var isJava = !isBrowser && /Java/.test(toString.call(root.java));
|
||||||
|
|
||||||
/** Add `console.log()` support for Narwhal, Rhino, and RingoJS */
|
/** Add `console.log()` support for Narwhal, Rhino, and RingoJS */
|
||||||
var console = window.console || (window.console = { 'log': window.print });
|
var console = root.console || (root.console = { 'log': root.print });
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@
|
|||||||
* @private (@public in the browser)
|
* @private (@public in the browser)
|
||||||
*/
|
*/
|
||||||
function run() {
|
function run() {
|
||||||
fbPanel = (fbPanel = window.document && document.getElementById('FirebugUI')) &&
|
fbPanel = (fbPanel = root.document && document.getElementById('FirebugUI')) &&
|
||||||
(fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) &&
|
(fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) &&
|
||||||
fbPanel.getElementById('fbPanel1');
|
fbPanel.getElementById('fbPanel1');
|
||||||
|
|
||||||
@@ -257,8 +257,8 @@
|
|||||||
lodash.extend(Benchmark.options, {
|
lodash.extend(Benchmark.options, {
|
||||||
'async': true,
|
'async': true,
|
||||||
'setup': '\
|
'setup': '\
|
||||||
var _ = window._,\
|
var _ = global._,\
|
||||||
lodash = window.lodash,\
|
lodash = global.lodash,\
|
||||||
belt = this.name == buildName ? lodash : _;\
|
belt = this.name == buildName ? lodash : _;\
|
||||||
\
|
\
|
||||||
var index,\
|
var index,\
|
||||||
@@ -2000,8 +2000,8 @@
|
|||||||
log(Benchmark.platform);
|
log(Benchmark.platform);
|
||||||
}
|
}
|
||||||
// in the browser, expose `run` to be called later
|
// in the browser, expose `run` to be called later
|
||||||
if (window.document && !window.phantom) {
|
if (root.document && !root.phantom) {
|
||||||
window.run = run;
|
root.run = run;
|
||||||
} else {
|
} else {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user