Update vendor folder.

Former-commit-id: dde7c53eee254e2f50608e65540893764ab8d9cb
This commit is contained in:
John-David Dalton
2012-07-10 14:26:35 -04:00
parent 3b37d7489f
commit db257778c0
6 changed files with 104 additions and 66 deletions

View File

@@ -1349,7 +1349,7 @@ _.isNumber(8.4 * 5;
### <a id="_isobjectvalue"></a>`_.isObject(value)` ### <a id="_isobjectvalue"></a>`_.isObject(value)`
<a href="#_isobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/v0.3.2/lodash.js#L2873 "View in source") [&#x24C9;][1] <a href="#_isobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/v0.3.2/lodash.js#L2873 "View in source") [&#x24C9;][1]
Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexps, `new Number(0)*`, and `new String('')`) Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexps, `new Number(0)`, and `new String('')`)*
#### Arguments #### Arguments
1. `value` *(Mixed)*: The value to check. 1. `value` *(Mixed)*: The value to check.

View File

@@ -114,25 +114,6 @@ suite.add('RegExp#test', function() {
// > Fastest is String#indexOf // > Fastest is String#indexOf
~~~ ~~~
## Cloning this repo
To clone this repository including all submodules, using Git 1.6.5 or later:
~~~ bash
git clone --recursive https://github.com/bestiejs/benchmark.js.git
cd benchmark.js
~~~
For older Git versions, just use:
~~~ bash
git clone https://github.com/bestiejs/benchmark.js.git
cd benchmark.js
git submodule update --init
~~~
Feel free to fork and send pull requests if you see improvements!
## Footnotes ## Footnotes
1. Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 5-15, Firefox 1.5-8, IE 6-10, Opera 9.25-11.52, Safari 2-5.1.1, Node.js 0.4.8-0.6.1, Narwhal 0.3.2, RingoJS 0.7-0.8, and Rhino 1.7RC3. 1. Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 5-15, Firefox 1.5-8, IE 6-10, Opera 9.25-11.52, Safari 2-5.1.1, Node.js 0.4.8-0.6.1, Narwhal 0.3.2, RingoJS 0.7-0.8, and Rhino 1.7RC3.

View File

@@ -37,6 +37,9 @@
/** Used to check if an object is extensible */ /** Used to check if an object is extensible */
var isExtensible = Object.isExtensible || function() { return true; }; var isExtensible = Object.isExtensible || function() { return true; };
/** Used to access Wade Simmons' Node microtime module */
var microtimeObject = req('microtime');
/** Used to access the browser's high resolution timer */ /** Used to access the browser's high resolution timer */
var perfObject = isHostType(window, 'performance') && performance; var perfObject = isHostType(window, 'performance') && performance;
@@ -46,6 +49,9 @@
perfObject.webkitNow && 'webkitNow' perfObject.webkitNow && 'webkitNow'
); );
/** Used to access Node's high resolution timer */
var processObject = isHostType(window, 'process') && process;
/** Used to check if an own property is enumerable */ /** Used to check if an own property is enumerable */
var propertyIsEnumerable = {}.propertyIsEnumerable; var propertyIsEnumerable = {}.propertyIsEnumerable;
@@ -678,7 +684,14 @@
start = toInteger(start); start = toInteger(start);
start = start < 0 ? max(length + start, 0) : min(start, length); start = start < 0 ? max(length + start, 0) : min(start, length);
deleteCount = min(max(toInteger(deleteCount), 0), length - start);
// support the de-facto SpiderMonkey extension
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/splice#Parameters
// https://bugs.ecmascript.org/show_bug.cgi?id=429
deleteCount = arguments.length == 1
? length - start
: min(max(toInteger(deleteCount), 0), length - start);
return insert.call(object, start, deleteCount, slice.call(arguments, 2)); return insert.call(object, start, deleteCount, slice.call(arguments, 2));
} }
@@ -1884,6 +1897,21 @@
* 'onCycle': onCycle, * 'onCycle': onCycle,
* 'onComplete': onComplete * 'onComplete': onComplete
* }); * });
*
* // or name and options
* suite.add('foo', {
* 'fn': fn,
* 'onCycle': onCycle,
* 'onComplete': onComplete
* });
*
* // or options only
* suite.add({
* 'name': 'foo',
* 'fn': fn,
* 'onCycle': onCycle,
* 'onComplete': onComplete
* });
*/ */
function add(name, fn, options) { function add(name, fn, options) {
var me = this, var me = this,
@@ -2509,7 +2537,7 @@
if (ns.stop) { if (ns.stop) {
ns.start(); ns.start();
while (!(measured = ns.microseconds())) { } while (!(measured = ns.microseconds())) { }
} else if (perfName) { } else if (ns[perfName]) {
divisor = 1e3; divisor = 1e3;
measured = Function('n', 'var r,s=n.' + perfName + '();while(!(r=n.' + perfName + '()-s)){};return r')(ns); measured = Function('n', 'var r,s=n.' + perfName + '();while(!(r=n.' + perfName + '()-s)){};return r')(ns);
} else { } else {
@@ -2519,8 +2547,14 @@
} }
else if (unit == 'ns') { else if (unit == 'ns') {
divisor = 1e9; divisor = 1e9;
begin = ns.nanoTime(); if (ns.nanoTime) {
while (!(measured = ns.nanoTime() - begin)) { } begin = ns.nanoTime();
while (!(measured = ns.nanoTime() - begin)) { }
} else {
begin = (begin = ns())[0] + (begin[1] / divisor);
while (!(measured = ((measured = ns())[0] + (measured[1] / divisor)) - begin)) { }
divisor = 1;
}
} }
else { else {
begin = new ns; begin = new ns;
@@ -2575,9 +2609,13 @@
timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' });
} }
// detect Node's microtime module: // detect Node's nanosecond resolution timer available in Node >= 0.8
// npm install microtime if (processObject && typeof (timer.ns = processObject.hrtime) == 'function') {
if ((timer.ns = (req('microtime') || { 'now': 0 }).now)) { timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' });
}
// detect Wade Simmons' Node microtime module
if (microtimeObject && typeof (timer.ns = microtimeObject.now) == 'function') {
timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' });
} }
@@ -2596,10 +2634,17 @@
} }
// use API of chosen timer // use API of chosen timer
if (timer.unit == 'ns') { if (timer.unit == 'ns') {
extend(template, { if (timer.ns.nanoTime) {
'begin': 's$=n$.nanoTime()', extend(template, {
'end': 'r$=(n$.nanoTime()-s$)/1e9' 'begin': 's$=n$.nanoTime()',
}); 'end': 'r$=(n$.nanoTime()-s$)/1e9'
});
} else {
extend(template, {
'begin': 's$=n$()',
'end': 'r$=n$(s$);r$=r$[0]+(r$[1]/1e9)'
});
}
} }
else if (timer.unit == 'us') { else if (timer.unit == 'us') {
if (timer.ns.stop) { if (timer.ns.stop) {

View File

@@ -87,9 +87,28 @@ class Generator {
* @returns {String} The formatted string. * @returns {String} The formatted string.
*/ */
private static function format($string) { private static function format($string) {
// mark numbers as code and italicize parentheses $counter = 0;
return trim(preg_replace('/(^|\s)(\([^)]+\))/', '$1*$2*',
preg_replace('/ (-?\d+(?:.\d+)?)(?!\.[^\n])/', ' `$1`', $string))); // tokenize inline code snippets
preg_match_all('/`[^`]+`/', $string, $tokenized);
$tokenized = $tokenized[0];
foreach ($tokenized as $snippet) {
$string = str_replace($snippet, '__token' . ($counter++) .'__', $string);
}
// italicize parentheses
$string = preg_replace('/(^|\s)(\([^)]+\))/', '$1*$2*', $string);
// mark numbers as inline code
$string = preg_replace('/ (-?\d+(?:.\d+)?)(?!\.[^\n])/', ' `$1`', $string);
// detokenize inline code snippets
$counter = 0;
foreach ($tokenized as $snippet) {
$string = str_replace('__token' . ($counter++) . '__', $snippet, $string);
}
return trim($string);
} }
/** /**

View File

@@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4 /** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.0.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * @license RequireJS 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license. * Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details * see: http://github.com/jrburke/requirejs for details
*/ */
@@ -10,9 +10,9 @@ var requirejs, require, define;
(function (global) { (function (global) {
'use strict'; 'use strict';
var version = '2.0.2', var version = '2.0.4',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/, jsSuffixRegExp = /\.js$/,
currDirRegExp = /^\.\//, currDirRegExp = /^\.\//,
ostring = Object.prototype.toString, ostring = Object.prototype.toString,
@@ -288,6 +288,7 @@ var requirejs, require, define;
*/ */
function normalize(name, baseName, applyMap) { function normalize(name, baseName, applyMap) {
var baseParts = baseName && baseName.split('/'), var baseParts = baseName && baseName.split('/'),
normalizedBaseParts = baseParts,
map = config.map, map = config.map,
starMap = map && map['*'], starMap = map && map['*'],
pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment, pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
@@ -302,17 +303,17 @@ var requirejs, require, define;
if (config.pkgs[baseName]) { if (config.pkgs[baseName]) {
//If the baseName is a package name, then just treat it as one //If the baseName is a package name, then just treat it as one
//name to concat the name with. //name to concat the name with.
baseParts = [baseName]; normalizedBaseParts = baseParts = [baseName];
} else { } else {
//Convert baseName to array, and lop off the last part, //Convert baseName to array, and lop off the last part,
//so that . matches that 'directory' and not name of the baseName's //so that . matches that 'directory' and not name of the baseName's
//module. For instance, baseName of 'one/two/three', maps to //module. For instance, baseName of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for //'one/two/three.js', but we want the directory, 'one/two' for
//this normalization. //this normalization.
baseParts = baseParts.slice(0, baseParts.length - 1); normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
} }
name = baseParts.concat(name.split('/')); name = normalizedBaseParts.concat(name.split('/'));
trimDots(name); trimDots(name);
//Some use of packages may use a . path to reference the //Some use of packages may use a . path to reference the
@@ -450,17 +451,7 @@ var requirejs, require, define;
} else { } else {
//A regular module. //A regular module.
normalizedName = normalize(name, parentName, applyMap); normalizedName = normalize(name, parentName, applyMap);
url = context.nameToUrl(normalizedName);
//Calculate url for the module, if it has a name.
//Use name here since nameToUrl also calls normalize,
//and for relative names that are outside the baseUrl
//this causes havoc. Was thinking of just removing
//parentModuleMap to avoid extra normalization, but
//normalize() still does a dot removal because of
//issue #142, so just pass in name here and redo
//the normalization. Paths outside baseUrl are just
//messy to support.
url = context.nameToUrl(name, null, parentModuleMap);
} }
} }
@@ -1583,20 +1574,21 @@ var requirejs, require, define;
moduleNamePlusExt = moduleNamePlusExt.substring(0, index); moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
} }
return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap); return context.nameToUrl(normalize(moduleNamePlusExt, relModuleMap && relModuleMap.id, true),
ext);
}, },
/** /**
* Converts a module name to a file path. Supports cases where * Converts a module name to a file path. Supports cases where
* moduleName may actually be just an URL. * moduleName may actually be just an URL.
* Note that it **does not** call normalize on the moduleName,
* it is assumed to have already been normalized. This is an
* internal API, not a public one. Use toUrl for the public API.
*/ */
nameToUrl: function (moduleName, ext, relModuleMap) { nameToUrl: function (moduleName, ext) {
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
parentPath; parentPath;
//Normalize module name if have a base relative module name to work from.
moduleName = normalize(moduleName, relModuleMap && relModuleMap.id, true);
//If a colon is in the URL, it indicates a protocol is used and it is just //If a colon is in the URL, it indicates a protocol is used and it is just
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
//or ends with .js, then assume the user meant to use an url and not a module id. //or ends with .js, then assume the user meant to use an url and not a module id.
@@ -1822,6 +1814,7 @@ var requirejs, require, define;
document.createElement('script'); document.createElement('script');
node.type = config.scriptType || 'text/javascript'; node.type = config.scriptType || 'text/javascript';
node.charset = 'utf-8'; node.charset = 'utf-8';
node.async = true;
node.setAttribute('data-requirecontext', context.contextName); node.setAttribute('data-requirecontext', context.contextName);
node.setAttribute('data-requiremodule', moduleName); node.setAttribute('data-requiremodule', moduleName);
@@ -1924,21 +1917,21 @@ var requirejs, require, define;
//baseUrl, if it is not already set. //baseUrl, if it is not already set.
dataMain = script.getAttribute('data-main'); dataMain = script.getAttribute('data-main');
if (dataMain) { if (dataMain) {
//Pull off the directory of data-main for use as the
//baseUrl.
src = dataMain.split('/');
mainScript = src.pop();
subPath = src.length ? src.join('/') + '/' : './';
//Set final baseUrl if there is not already an explicit one. //Set final baseUrl if there is not already an explicit one.
if (!cfg.baseUrl) { if (!cfg.baseUrl) {
//Pull off the directory of data-main for use as the
//baseUrl.
src = dataMain.split('/');
mainScript = src.pop();
subPath = src.length ? src.join('/') + '/' : './';
cfg.baseUrl = subPath; cfg.baseUrl = subPath;
dataMain = mainScript;
} }
//Strip off any trailing .js since dataMain is now //Strip off any trailing .js since dataMain is now
//like a module name. //like a module name.
dataMain = mainScript.replace(jsSuffixRegExp, ''); dataMain = dataMain.replace(jsSuffixRegExp, '');
//Put the data-main script in the files to load. //Put the data-main script in the files to load.
cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];