mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Fix test/test.js in lodash-node and carry fixes over to perf/perf.js.
This commit is contained in:
43
perf/perf.js
43
perf/perf.js
@@ -15,14 +15,6 @@
|
|||||||
params = root.arguments,
|
params = root.arguments,
|
||||||
system = root.system;
|
system = root.system;
|
||||||
|
|
||||||
/** Detect if running in Java */
|
|
||||||
var isJava = !document && !!root.java;
|
|
||||||
|
|
||||||
/** Use a single "load" function */
|
|
||||||
var load = (typeof require == 'function' && !amd)
|
|
||||||
? require
|
|
||||||
: (isJava && root.load) || noop;
|
|
||||||
|
|
||||||
/** 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,
|
||||||
@@ -44,12 +36,33 @@
|
|||||||
|
|
||||||
if (!amd) {
|
if (!amd) {
|
||||||
try {
|
try {
|
||||||
return require.resolve(result);
|
result = require('fs').realpathSync(result);
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = require.resolve(result);
|
||||||
} catch(e) { }
|
} catch(e) { }
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
/** The `ui` object */
|
||||||
|
var ui = root.ui || (root.ui = {
|
||||||
|
'buildPath': basename(filePath, '.js'),
|
||||||
|
'otherPath': 'underscore'
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Detect if in a browser environment */
|
||||||
|
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
|
||||||
|
|
||||||
|
/** Detect if in a Java environment */
|
||||||
|
var isJava = !isBrowser && /Java/.test(toString.call(root.java));
|
||||||
|
|
||||||
|
/** Use a single "load" function */
|
||||||
|
var load = (typeof require == 'function' && !amd)
|
||||||
|
? require
|
||||||
|
: (isJava && root.load) || noop;
|
||||||
|
|
||||||
/** Load Lo-Dash */
|
/** Load Lo-Dash */
|
||||||
var lodash = root.lodash || (root.lodash = (
|
var lodash = root.lodash || (root.lodash = (
|
||||||
lodash = load(filePath) || root._,
|
lodash = load(filePath) || root._,
|
||||||
@@ -92,12 +105,6 @@
|
|||||||
/** Used to resolve a value's internal [[Class]] */
|
/** Used to resolve a value's internal [[Class]] */
|
||||||
var toString = Object.prototype.toString;
|
var toString = Object.prototype.toString;
|
||||||
|
|
||||||
/** The `ui` object */
|
|
||||||
var ui = root.ui || (root.ui = {
|
|
||||||
'buildPath': basename(filePath, '.js'),
|
|
||||||
'otherPath': 'underscore'
|
|
||||||
});
|
|
||||||
|
|
||||||
/** The Lo-Dash build basename */
|
/** The Lo-Dash build basename */
|
||||||
var buildName = root.buildName = basename(ui.buildPath, '.js');
|
var buildName = root.buildName = basename(ui.buildPath, '.js');
|
||||||
|
|
||||||
@@ -107,12 +114,6 @@
|
|||||||
return result + (result == buildName ? ' (2)' : '');
|
return result + (result == buildName ? ' (2)' : '');
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/** Detect if in a browser environment */
|
|
||||||
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
|
|
||||||
|
|
||||||
/** Detect Java environment */
|
|
||||||
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 = root.console || (root.console = { 'log': root.print });
|
var console = root.console || (root.console = { 'log': root.print });
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,11 @@
|
|||||||
|
|
||||||
if (!amd) {
|
if (!amd) {
|
||||||
try {
|
try {
|
||||||
return require.resolve(result);
|
result = require('fs').realpathSync(result);
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = require.resolve(result);
|
||||||
} catch(e) { }
|
} catch(e) { }
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -65,7 +69,7 @@
|
|||||||
/** The basename of the Lo-Dash file to test */
|
/** The basename of the Lo-Dash file to test */
|
||||||
var basename = /[\w.-]+$/.exec(filePath)[0];
|
var basename = /[\w.-]+$/.exec(filePath)[0];
|
||||||
|
|
||||||
/** Detect if running in Java */
|
/** Detect if in a Java environment */
|
||||||
var isJava = !document && !!root.java;
|
var isJava = !document && !!root.java;
|
||||||
|
|
||||||
/** Used to indicate testing a modularized build */
|
/** Used to indicate testing a modularized build */
|
||||||
|
|||||||
Reference in New Issue
Block a user