Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

vendor/platform.js/LICENSE.txt

155

build.js

@@ -23,2 +23,11 @@ #!/usr/bin/env node

/**
* Flag used to specify `_.bindAll`, `_.extend`, and `_.defaults` are
* constructed using the "use strict" directive.
*/
var isStrict = process.argv.indexOf('strict') > -1;
/** Flag used to specify if the build should include the "use strict" directive */
var useStrict = isStrict || !(isLegacy || isMobile);
/** Shortcut used to convert array-like objects to arrays */

@@ -34,2 +43,10 @@ var slice = [].slice;

if (isStrict) {
source = setUseStrictOption(source, true);
}
else if (!useStrict) {
source = removeUseStrictDirective(source);
source = setUseStrictOption(source, false);
}
if (isLegacy) {

@@ -229,3 +246,2 @@ ['isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'].forEach(function(varName) {

'isKeysFast',
'iteratee',
'object',

@@ -236,3 +252,4 @@ 'objectBranch',

'top',
'useHas'
'useHas',
'useStrict'
];

@@ -269,2 +286,30 @@

/**
* Logs the help message to the console.
*
* @private
*/
function displayHelp() {
console.log([
'',
' Commands:',
'',
' lodash backbone Build containing all methods required by Backbone',
' lodash legacy Build tailored for older browsers without ES5 support',
' lodash mobile Build with IE < 9 bug fixes and method compilation removed',
' lodash strict Build with `_.bindAll`, `_.extend`, and `_.defaults` in strict mode',
' lodash category=... Comma separated categories of methods to include in the build',
' lodash exclude=... Comma separated names of methods to exclude from the build',
' lodash include=... Comma separated names of methods to include in the build',
'',
' All arguments, except `exclude` with `include` and `legacy` with `mobile`, may be combined.',
'',
' Options:',
'',
' -h, --help Display help information',
' -V, --version Output current version of Lo-Dash',
''
].join('\n'));
}
/**
* Gets the aliases associated with a given function name.

@@ -477,2 +522,4 @@ *

return removeVar(source, 'isKeysFast')
// remove optimized branch in `iteratorTemplate`
.replace(/(?: *\/\/.*\n)*\s*'( *)<% *if *\(isKeysFast[\s\S]+?'\1<% *} *else *\{ *%>.+\n([\s\S]+?) *'\1<% *} *%>.+/, '$2')
// remove `isKeysFast` from `beforeLoop.object` of `mapIteratorOptions`

@@ -483,8 +530,17 @@ .replace(/=\s*'\s*\+\s*\(isKeysFast.+/, "= []'")

// remove data object property assignment in `createIterator`
.replace(/\s*.+?\.isKeysFast *=.+/, '')
// remove optimized branch in `iteratorTemplate`
.replace(/(?: *\/\/.*\n)*\s*'( *)<% *if *\(isKeysFast[\s\S]+?'\1<% *} *else *\{ *%>.+\n([\s\S]+?) *'\1<% *} *%>.+/, '$2');
.replace(/\s*.+?\.isKeysFast *=.+/, '');
}
/**
* Removes the "use strict" directive from `source`.
*
* @private
* @param {String} source The source to process.
* @returns {String} Returns the modified source.
*/
function removeUseStrictDirective(source) {
return source.replace(/(["'])use strict\1;( *\n)?/, '');
}
/**
* Removes a given variable from `source`.

@@ -545,4 +601,40 @@ *

/**
* Hard-codes the `useStrict` template option value for `iteratorTemplate`.
*
* @private
* @param {String} source The source to process.
* @param {Boolean} value The value to set.
* @returns {String} Returns the modified source.
*/
function setUseStrictOption(source, value) {
return source
// replace `useStrict` branch in `value` with hard-coded option
.replace(/(?: *\/\/.*\n)*(\s*)' *<% *if *\(useStrict\).+/, value ? "$1'\\'use strict\\';\\n' +" : '')
// remove `useStrict` from iterator options
.replace(/ *'useStrict': *false,\n/g, '')
// remove `useStrict` data object property assignment in `createIterator`
.replace(/\s*.+?\.useStrict *=.+/, '');
}
/*--------------------------------------------------------------------------*/
// display help message
if (lodash.find(process.argv, function(arg) {
return /^(?:-h|--help)$/.test(arg);
})) {
displayHelp();
process.exit();
}
// display `lodash.VERSION`
if (lodash.find(process.argv, function(arg) {
return /^(?:-V|--version)$/.test(arg);
})) {
console.log(lodash.VERSION);
process.exit();
}
/*--------------------------------------------------------------------------*/
// Backbone build

@@ -807,9 +899,3 @@ if (isBackbone) {

iteratorOptions.forEach(function(property) {
if (property == 'iteratee') {
// use a more fine-grained regexp for the `iteratee` property because
// it's a compiled variable as well as a data property
snippet = snippet.replace(/(__t *= *\( *)(iteratee)/, '$1obj.$2');
} else {
snippet = snippet.replace(RegExp('([^\\w.])\\b' + property + '\\b', 'g'), '$1obj.' + property);
}
snippet = snippet.replace(RegExp('([^\\w.])\\b' + property + '\\b', 'g'), '$1obj.' + property);
});

@@ -845,2 +931,12 @@

// remove associated functions, variables, and code snippets that the minifier may miss
if (isRemoved(source, 'bind')) {
source = removeVar(source, 'nativeBind');
source = removeVar(source, 'isBindFast');
}
if (isRemoved(source, 'isArray')) {
source = removeVar(source, 'nativeIsArray');
}
if (isRemoved(source, 'keys')) {
source = removeFunction(source, 'shimKeys');
}
if (isRemoved(source, 'mixin')) {

@@ -864,33 +960,23 @@ // remove `LoDash` constructor

}
if (isRemoved(source, 'isArray', 'isEmpty', 'isEqual', 'size')) {
if (isRemoved(source, 'isArray', 'isEmpty', 'isEqual')) {
source = removeVar(source, 'arrayClass');
}
if (isRemoved(source, 'bind', 'functions', 'groupBy', 'invoke', 'isEqual', 'isFunction', 'result', 'sortBy', 'toArray')) {
if (isRemoved(source, 'bind', 'bindAll', 'functions', 'isEqual', 'isFunction', 'result', 'toArray')) {
source = removeVar(source, 'funcClass');
}
if (isRemoved(source, 'bind')) {
source = removeVar(source, 'nativeBind');
source = removeVar(source, 'isBindFast');
}
if (isRemoved(source, 'isArray')) {
source = removeVar(source, 'nativeIsArray');
}
if (isRemoved(source, 'keys')) {
source = removeFunction(source, 'shimKeys');
}
if (isRemoved(source, 'clone', 'isObject', 'keys')) {
if (isRemoved(source, 'bind', 'clone', 'isObject', 'keys')) {
source = removeVar(source, 'objectTypes');
}
if (isRemoved(source, 'bind', 'isArray', 'keys')) {
source = removeVar(source, 'reNative');
}
if (isRemoved(source, 'isEmpty', 'isEqual', 'isString', 'size')) {
source = removeVar(source, 'stringClass');
}
if ((source.match(/\bcreateIterator\b/g) || []).length < 2) {
source = removeFunction(source, 'createIterator');
}
if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'keys')) {
source = removeVar(source, 'reNative');
}
if (isRemoved(source, 'createIterator', 'extend', 'isEqual')) {
source = removeVar(source, 'hasDontEnumBug');
}
if (isRemoved(source, 'createIterator', 'contains', 'isEmpty', 'isEqual', 'isString')) {
source = removeVar(source, 'stringClass');
}
if (isRemoved(source, 'createIterator', 'keys')) {

@@ -915,5 +1001,10 @@ source = removeVar(source, 'nativeKeys');

// begin the minification process
if (filterType || isBackbone || isLegacy || isMobile) {
if (filterType || isBackbone || isLegacy || isMobile || isStrict) {
fs.writeFileSync(path.join(cwd, 'lodash.custom.js'), source);
minify(source, 'lodash.custom.min', function(result) {
// re-remove "use strict" added by the minifier
if (!useStrict) {
result = removeUseStrictDirective(result);
}
fs.writeFileSync(path.join(cwd, 'lodash.custom.min.js'), result);

@@ -920,0 +1011,0 @@ });

@@ -37,5 +37,2 @@ #!/usr/bin/env node

// use double quotes consistently
source = source.replace(/'use strict'/, '"use strict"');
// unescape properties (i.e. foo["bar"] => foo.bar)

@@ -42,0 +39,0 @@ source = source.replace(/(\w)\["([^."]+)"\]/g, '$1.$2');

@@ -13,2 +13,3 @@ #!/usr/bin/env node

'arrayClass',
'bind',
'callback',

@@ -20,2 +21,3 @@ 'className',

'funcClass',
'funcs',
'hasOwnProperty',

@@ -26,2 +28,3 @@ 'identity',

'iteratee',
'iterateeIndex',
'iteratorBind',

@@ -42,4 +45,2 @@ 'length',

'slice',
'source',
'sourceIndex',
'stringClass',

@@ -65,3 +66,2 @@ 'target',

'isKeysFast',
'iteratee',
'object',

@@ -72,3 +72,4 @@ 'objectBranch',

'top',
'useHas'
'useHas',
'useStrict'
];

@@ -75,0 +76,0 @@

{
"name": "lodash",
"version": "0.4.1",
"version": "0.4.2",
"description": "A drop-in replacement for Underscore.js that delivers performance improvements, bug fixes, and additional features.",

@@ -5,0 +5,0 @@ "homepage": "http://lodash.com",

@@ -28,6 +28,4 @@ (function(window) {

/** Used to access the Firebug Lite panel */
var fbPanel = (fbPanel = window.document && document.getElementById('FirebugUI')) &&
(fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) &&
fbPanel.getElementById('fbPanel1');
/** Used to access the Firebug Lite panel (set by `run`) */
var fbPanel;

@@ -76,2 +74,16 @@ /** Used to score Lo-Dash and Underscore performance */

/**
* Runs all benchmark suites.
*
* @private (@public in the browser)
*/
function run() {
fbPanel = (fbPanel = window.document && document.getElementById('FirebugUI')) &&
(fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) &&
fbPanel.getElementById('fbPanel1');
log('\nSit back and relax, this may take a while.');
suites[0].run();
}
/*--------------------------------------------------------------------------*/

@@ -84,7 +96,10 @@

_ = window._,
lodash = window.lodash;
lodash = window.lodash,
belt = this.name == 'Lo-Dash' ? lodash : _;
var length = 20,
numbers = [],
var index,
limit = 20,
object = {},
objects = Array(limit),
numbers = Array(limit),
fourNumbers = [5, 25, 10, 30],

@@ -94,142 +109,220 @@ nestedNumbers = [1, [2], [3, [[4]]]],

var ctor = function() { };
for (index = 0; index < limit; index++) {
numbers[index] = index;
object['key' + index] = index;
objects[index] = { 'num': index };
}
var func = function(greeting, punctuation) {
return greeting + ', ' + this.name + (punctuation || '.');
};
if (typeof bind != 'undefined') {
var contextObject = { 'name': 'moe' },
ctor = function() {};
var lodashBoundNormal = lodash.bind(func, { 'name': 'moe' }),
lodashBoundCtor = lodash.bind(ctor, { 'name': 'moe' }),
lodashBoundPartial = lodash.bind(func, { 'name': 'moe' }, 'hi');
var func = function(greeting, punctuation) {
return greeting + ', ' + this.name + (punctuation || '.');
};
var _boundNormal = _.bind(func, { 'name': 'moe' }),
_boundCtor = _.bind(ctor, { 'name': 'moe' }),
_boundPartial = _.bind(func, { 'name': 'moe' }, 'hi');
var lodashBoundNormal = lodash.bind(func, contextObject),
lodashBoundCtor = lodash.bind(ctor, contextObject),
lodashBoundPartial = lodash.bind(func, contextObject, 'hi');
var tplData = {
'header1': 'Header1',
'header2': 'Header2',
'header3': 'Header3',
'header4': 'Header4',
'header5': 'Header5',
'header6': 'Header6',
'list': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
};
var _boundNormal = _.bind(func, contextObject),
_boundCtor = _.bind(ctor, contextObject),
_boundPartial = _.bind(func, contextObject, 'hi');
}
var tplBase =
'<div>' +
"<h1 class='header1'><%= header1 %></h1>" +
"<h2 class='header2'><%= header2 %></h2>" +
"<h3 class='header3'><%= header3 %></h3>" +
"<h4 class='header4'><%= header4 %></h4>" +
"<h5 class='header5'><%= header5 %></h5>" +
"<h6 class='header6'><%= header6 %></h6>";
if (typeof bindAll != 'undefined') {
var bindAllObjects = Array(this.count),
funcNames = belt.functions(lodash);
var tpl =
tplBase +
"<ul class='list'>" +
"<li class='item'><%= list[0] %></li>" +
"<li class='item'><%= list[1] %></li>" +
"<li class='item'><%= list[2] %></li>" +
"<li class='item'><%= list[3] %></li>" +
"<li class='item'><%= list[4] %></li>" +
"<li class='item'><%= list[5] %></li>" +
"<li class='item'><%= list[6] %></li>" +
"<li class='item'><%= list[7] %></li>" +
"<li class='item'><%= list[8] %></li>" +
"<li class='item'><%= list[9] %></li>" +
'</ul>' +
'</div>';
// potentially expensive
for (index = 0; index < this.count; index++) {
bindAllObjects[index] = belt.clone(lodash);
}
}
var tplWithEvaluate =
tplBase +
"<ul class='list'>" +
'<% for (var index = 0, length = list.length; index < length; index++) { %>' +
"<li class='item'><%= list[index] %></li>" +
'<% } %>' +
'</ul>' +
'</div>';
if (typeof groupBy != 'undefined') {
var wordToNumber = {
'one': 1,
'two': 2,
'three': 3,
'four': 4,
'five': 5,
'six': 6,
'seven': 7,
'eight': 8,
'nine': 9,
'ten': 10,
'eleven': 11,
'twelve': 12,
'thirteen': 13,
'fourteen': 14,
'fifteen': 15,
'sixteen': 16,
'seventeen': 17,
'eighteen': 18,
'nineteen': 19,
'twenty': 20,
'twenty-one': 21,
'twenty-two': 22,
'twenty-three': 23,
'twenty-four': 24,
'twenty-five': 25
};
var tplBaseVerbose =
'<div>' +
"<h1 class='header1'><%= data.header1 %></h1>" +
"<h2 class='header2'><%= data.header2 %></h2>" +
"<h3 class='header3'><%= data.header3 %></h3>" +
"<h4 class='header4'><%= data.header4 %></h4>" +
"<h5 class='header5'><%= data.header5 %></h5>" +
"<h6 class='header6'><%= data.header6 %></h6>";
var words = belt.keys(wordToNumber).slice(0, limit);
}
var tplVerbose =
tplBaseVerbose +
"<ul class='list'>" +
"<li class='item'><%= data.list[0] %></li>" +
"<li class='item'><%= data.list[1] %></li>" +
"<li class='item'><%= data.list[2] %></li>" +
"<li class='item'><%= data.list[3] %></li>" +
"<li class='item'><%= data.list[4] %></li>" +
"<li class='item'><%= data.list[5] %></li>" +
"<li class='item'><%= data.list[6] %></li>" +
"<li class='item'><%= data.list[7] %></li>" +
"<li class='item'><%= data.list[8] %></li>" +
"<li class='item'><%= data.list[9] %></li>" +
'</ul>' +
'</div>';
if (typeof isEqual != 'undefined') {
var objectOfPrimitives = {
'boolean': true,
'number': 1,
'string': 'a'
};
var tplVerboseWithEvaluate =
tplBaseVerbose +
"<ul class='list'>" +
'<% for (var index = 0, length = data.list.length; index < length; index++) { %>' +
"<li class='item'><%= data.list[index] %></li>" +
'<% } %>' +
'</ul>' +
'</div>';
var objectOfObjects = {
'boolean': new Boolean(true),
'number': new Number(1),
'string': new String('a')
};
var lodashTpl = lodash.template(tpl),
lodashTplWithEvaluate = lodash.template(tplWithEvaluate),
lodashTplVerbose = lodash.template(tplVerbose, null, { 'variable': 'data' }),
lodashTplVerboseWithEvaluate = lodash.template(tplVerboseWithEvaluate, null, { 'variable': 'data' });
var object2 = {},
objects2 = Array(limit),
numbers2 = Array(limit),
nestedNumbers2 = [1, [2], [3, [[4]]]];
var _tpl = _.template(tpl),
_tplWithEvaluate = _.template(tplWithEvaluate),
_tplVerbose = _.template(tplVerbose, null, { 'variable': 'data' }),
_tplVerboseWithEvaluate = _.template(tplVerboseWithEvaluate, null, { 'variable': 'data' });
for (index = 0; index < limit; index++) {
numbers2[index] = index;
object2['key' + index] = index;
objects2[index] = { 'num': index };
}
}
var wordToNumber = {
'one': 1,
'two': 2,
'three': 3,
'four': 4,
'five': 5,
'six': 6,
'seven': 7,
'eight': 8,
'nine': 9,
'ten': 10,
'eleven': 11,
'twelve': 12,
'thirteen': 13,
'fourteen': 14,
'fifteen': 15,
'sixteen': 16,
'seventeen': 17,
'eighteen': 18,
'nineteen': 19,
'twenty': 20,
'twenty-one': 21,
'twenty-two': 22,
'twenty-three': 23,
'twenty-four': 24,
'twenty-five': 25
};
if (typeof multiArrays != 'undefined') {
var twentyFiveValues = Array(25),
twentyFiveValues2 = Array(25),
fiftyValues = Array(50),
fiftyValues2 = Array(50),
seventyFiveValues = Array(75),
seventyFiveValues2 = Array(75),
lowerChars = 'abcdefghijklmnopqrstuvwxyz'.split(''),
upperChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var words = _.keys(wordToNumber).slice(0, length);
for (index = 0; index < 75; index++) {
if (index < 26) {
if (index < 20) {
twentyFiveValues[index] = lowerChars[index];
twentyFiveValues2[index] = upperChars[index];
}
else if (index < 25) {
twentyFiveValues[index] =
twentyFiveValues2[index] = index;
}
fiftyValues[index] =
seventyFiveValues[index] = lowerChars[index];
for (var index = 0; index < length; index++) {
numbers[index] = index;
object['key' + index] = index;
fiftyValues2[index] =
seventyFiveValues2[index] = upperChars[index];
}
else {
if (index < 50) {
fiftyValues[index] = index;
fiftyValues2[index] = index + (index < 40 ? 75 : 0);
}
seventyFiveValues[index] = index;
seventyFiveValues2[index] = index + (index < 60 ? 75 : 0);
}
}
}
var objects = lodash.map(numbers, function(num) {
return { 'num': num };
});
if (typeof template != 'undefined') {
var tplData = {
'header1': 'Header1',
'header2': 'Header2',
'header3': 'Header3',
'header4': 'Header4',
'header5': 'Header5',
'header6': 'Header6',
'list': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
};
var tplBase =
'<div>' +
"<h1 class='header1'><%= header1 %></h1>" +
"<h2 class='header2'><%= header2 %></h2>" +
"<h3 class='header3'><%= header3 %></h3>" +
"<h4 class='header4'><%= header4 %></h4>" +
"<h5 class='header5'><%= header5 %></h5>" +
"<h6 class='header6'><%= header6 %></h6>";
var tpl =
tplBase +
"<ul class='list'>" +
"<li class='item'><%= list[0] %></li>" +
"<li class='item'><%= list[1] %></li>" +
"<li class='item'><%= list[2] %></li>" +
"<li class='item'><%= list[3] %></li>" +
"<li class='item'><%= list[4] %></li>" +
"<li class='item'><%= list[5] %></li>" +
"<li class='item'><%= list[6] %></li>" +
"<li class='item'><%= list[7] %></li>" +
"<li class='item'><%= list[8] %></li>" +
"<li class='item'><%= list[9] %></li>" +
'</ul>' +
'</div>';
var tplWithEvaluate =
tplBase +
"<ul class='list'>" +
'<% for (var index = 0, length = list.length; index < length; index++) { %>' +
"<li class='item'><%= list[index] %></li>" +
'<% } %>' +
'</ul>' +
'</div>';
var tplBaseVerbose =
'<div>' +
"<h1 class='header1'><%= data.header1 %></h1>" +
"<h2 class='header2'><%= data.header2 %></h2>" +
"<h3 class='header3'><%= data.header3 %></h3>" +
"<h4 class='header4'><%= data.header4 %></h4>" +
"<h5 class='header5'><%= data.header5 %></h5>" +
"<h6 class='header6'><%= data.header6 %></h6>";
var tplVerbose =
tplBaseVerbose +
"<ul class='list'>" +
"<li class='item'><%= data.list[0] %></li>" +
"<li class='item'><%= data.list[1] %></li>" +
"<li class='item'><%= data.list[2] %></li>" +
"<li class='item'><%= data.list[3] %></li>" +
"<li class='item'><%= data.list[4] %></li>" +
"<li class='item'><%= data.list[5] %></li>" +
"<li class='item'><%= data.list[6] %></li>" +
"<li class='item'><%= data.list[7] %></li>" +
"<li class='item'><%= data.list[8] %></li>" +
"<li class='item'><%= data.list[9] %></li>" +
'</ul>' +
'</div>';
var tplVerboseWithEvaluate =
tplBaseVerbose +
"<ul class='list'>" +
'<% for (var index = 0, length = data.list.length; index < length; index++) { %>' +
"<li class='item'><%= data.list[index] %></li>" +
'<% } %>' +
'</ul>' +
'</div>';
var settingsObject = { 'variable': 'data' };
var lodashTpl = lodash.template(tpl),
lodashTplWithEvaluate = lodash.template(tplWithEvaluate),
lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject),
lodashTplVerboseWithEvaluate = lodash.template(tplVerboseWithEvaluate, null, settingsObject);
var _tpl = _.template(tpl),
_tplWithEvaluate = _.template(tplWithEvaluate),
_tplVerbose = _.template(tplVerbose, null, settingsObject),
_tplVerboseWithEvaluate = _.template(tplVerboseWithEvaluate, null, settingsObject);
}
}

@@ -299,7 +392,13 @@ });

Benchmark.Suite('`_.bind` (uses native `Function#bind` if available and inferred fast)')
.add('Lo-Dash', function() {
lodash.bind(func, { 'name': 'moe' }, 'hi');
.add('Lo-Dash', {
'fn': function() {
lodash.bind(func, { 'name': 'moe' }, 'hi');
},
'teardown': 'function bind(){}'
})
.add('Underscore', function() {
_.bind(func, { 'name': 'moe' }, 'hi');
.add('Underscore', {
'fn': function() {
_.bind(func, { 'name': 'moe' }, 'hi');
},
'teardown': 'function bind(){}'
})

@@ -310,7 +409,13 @@ );

Benchmark.Suite('bound call')
.add('Lo-Dash', function() {
lodashBoundNormal();
.add('Lo-Dash', {
'fn': function() {
lodashBoundNormal();
},
'teardown': 'function bind(){}'
})
.add('Underscore', function() {
_boundNormal();
.add('Underscore', {
'fn': function() {
_boundNormal();
},
'teardown': 'function bind(){}'
})

@@ -321,7 +426,13 @@ );

Benchmark.Suite('bound call with arguments')
.add('Lo-Dash', function() {
lodashBoundNormal('hi', '!');
.add('Lo-Dash', {
'fn': function() {
lodashBoundNormal('hi', '!');
},
'teardown': 'function bind(){}'
})
.add('Underscore', function() {
_boundNormal('hi', '!');
.add('Underscore', {
'fn': function() {
_boundNormal('hi', '!');
},
'teardown': 'function bind(){}'
})

@@ -332,7 +443,13 @@ );

Benchmark.Suite('bound and partially applied call (uses native `Function#bind` if available)')
.add('Lo-Dash', function() {
lodashBoundPartial();
.add('Lo-Dash', {
'fn': function() {
lodashBoundPartial();
},
'teardown': 'function bind(){}'
})
.add('Underscore', function() {
_boundPartial();
.add('Underscore', {
'fn': function() {
_boundPartial();
},
'teardown': 'function bind(){}'
})

@@ -343,7 +460,13 @@ );

Benchmark.Suite('bound and partially applied call with arguments (uses native `Function#bind` if available)')
.add('Lo-Dash', function() {
lodashBoundPartial('!');
.add('Lo-Dash', {
'fn': function() {
lodashBoundPartial('!');
},
'teardown': 'function bind(){}'
})
.add('Underscore', function() {
_boundPartial('!');
.add('Underscore', {
'fn': function() {
_boundPartial('!');
},
'teardown': 'function bind(){}'
})

@@ -354,10 +477,110 @@ );

Benchmark.Suite('bound and called in a `new` expression, i.e. `new bound` (edge case)')
.add('Lo-Dash', {
'fn': function() {
new lodashBoundCtor();
},
'teardown': 'function bind(){}'
})
.add('Underscore', {
'fn': function() {
new _boundCtor();
},
'teardown': 'function bind(){}'
})
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.bindAll` iterating arguments')
.add('Lo-Dash', {
'fn': function() {
lodash.bindAll.apply(lodash, [bindAllObjects.pop()].concat(funcNames));
},
'teardown': 'function bindAll(){}'
})
.add('Underscore', {
'fn': function() {
_.bindAll.apply(_, [bindAllObjects.pop()].concat(funcNames));
},
'teardown': 'function bindAll(){}'
})
);
suites.push(
Benchmark.Suite('`_.bindAll` iterating the `object`')
.add('Lo-Dash', {
'fn': function() {
lodash.bindAll(bindAllObjects.pop());
},
'teardown': 'function bindAll(){}'
})
.add('Underscore', {
'fn': function() {
_.bindAll(bindAllObjects.pop());
},
'teardown': 'function bindAll(){}'
})
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.difference`')
.add('Lo-Dash', function() {
new lodashBoundCtor();
lodash.difference(numbers, fourNumbers, twoNumbers);
})
.add('Underscore', function() {
new _boundCtor();
_.difference(numbers, fourNumbers, twoNumbers);
})
);
suites.push(
Benchmark.Suite('`_.difference` iterating 25 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.difference(twentyFiveValues, twentyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.difference(twentyFiveValues, twentyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.difference` iterating 50 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.difference(fiftyValues, fiftyValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.difference(fiftyValues, fiftyValues2);
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.difference` iterating 75 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.difference(seventyFiveValues, seventyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.difference(seventyFiveValues, seventyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
);
/*--------------------------------------------------------------------------*/

@@ -476,3 +699,3 @@

.add('Lo-Dash', function() {
lodash.find(numbers, function(value, key) {
lodash.find(object, function(value, key) {
return /\D9$/.test(key);

@@ -482,3 +705,3 @@ });

.add('Underscore', function() {
_.find(numbers, function(value, key) {
_.find(object, function(value, key) {
return /\D9$/.test(key);

@@ -514,8 +737,8 @@ });

suites.push(
Benchmark.Suite('`_.difference`')
Benchmark.Suite('`_.functions`')
.add('Lo-Dash', function() {
lodash.difference(numbers, fourNumbers, twoNumbers);
lodash.functions(lodash);
})
.add('Underscore', function() {
_.difference(numbers, fourNumbers, twoNumbers);
_.functions(lodash);
})

@@ -538,7 +761,13 @@ );

Benchmark.Suite('`_.groupBy` with `property` name iterating an array')
.add('Lo-Dash', function() {
lodash.groupBy(words, 'length');
.add('Lo-Dash', {
'fn': function() {
lodash.groupBy(words, 'length');
},
'teardown': 'function groupBy(){}'
})
.add('Underscore', function() {
_.groupBy(words, 'length');
.add('Underscore', {
'fn': function() {
_.groupBy(words, 'length');
},
'teardown': 'function groupBy(){}'
})

@@ -549,7 +778,13 @@ );

Benchmark.Suite('`_.groupBy` with `callback` iterating an object')
.add('Lo-Dash', function() {
lodash.groupBy(wordToNumber, function(num) { return num >> 1; });
.add('Lo-Dash', {
'fn': function() {
lodash.groupBy(wordToNumber, function(num) { return num >> 1; });
},
'teardown': 'function groupBy(){}'
})
.add('Underscore', function() {
_.groupBy(wordToNumber, function(num) { return num >> 1; });
.add('Underscore', {
'fn': function() {
_.groupBy(wordToNumber, function(num) { return num >> 1; });
},
'teardown': 'function groupBy(){}'
})

@@ -592,5 +827,167 @@ );

suites.push(
Benchmark.Suite('`_.intersection` iterating 25 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.intersection(twentyFiveValues, twentyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.intersection(twentyFiveValues, twentyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.intersection` iterating 50 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.intersection(fiftyValues, fiftyValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.intersection(fiftyValues, fiftyValues2);
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.intersection` iterating 75 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.intersection(seventyFiveValues, seventyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.intersection(seventyFiveValues, seventyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.invoke` iterating an array')
.add('Lo-Dash', function() {
lodash.invoke(numbers, 'toFixed', '2');
})
.add('Underscore', function() {
_.invoke(numbers, 'toFixed', '2');
})
);
suites.push(
Benchmark.Suite('`_.invoke` with a function for `methodName` iterating an array')
.add('Lo-Dash', function() {
lodash.invoke(numbers, String.prototype.split, '');
})
.add('Underscore', function() {
_.invoke(numbers, String.prototype.split, '');
})
);
suites.push(
Benchmark.Suite('`_.invoke` iterating an object')
.add('Lo-Dash', function() {
lodash.invoke(object, 'toFixed', '2');
})
.add('Underscore', function() {
_.invoke(object, 'toFixed', '2');
})
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.isEqual` comparing primitives and objects (edge case)')
.add('Lo-Dash', {
'fn': function() {
lodash.isEqual(objectOfPrimitives, objectOfObjects);
},
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
'fn': function() {
_.isEqual(objectOfPrimitives, objectOfObjects);
},
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing arrays')
.add('Lo-Dash', {
'fn': function() {
lodash.isEqual(numbers, numbers2);
},
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
'fn': function() {
_.isEqual(numbers, numbers2);
},
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing nested arrays')
.add('Lo-Dash', {
'fn': function() {
lodash.isEqual(nestedNumbers, nestedNumbers2);
},
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
'fn': function() {
_.isEqual(nestedNumbers, nestedNumbers2);
},
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing arrays of objects')
.add('Lo-Dash', {
'fn': function() {
lodash.isEqual(objects, objects2);
},
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
'fn': function() {
_.isEqual(objects, objects2);
},
'teardown': 'function isEqual(){}'
})
);
suites.push(
Benchmark.Suite('`_.isEqual` comparing objects')
.add('Lo-Dash', {
'fn': function() {
lodash.isEqual(object, object2);
},
'teardown': 'function isEqual(){}'
})
.add('Underscore', {
'fn': function() {
_.isEqual(object, object2);
},
'teardown': 'function isEqual(){}'
})
);
/*--------------------------------------------------------------------------*/
suites.push(
Benchmark.Suite('`_.keys` (uses native `Object.keys` if available)')

@@ -767,7 +1164,13 @@ .add('Lo-Dash', function() {

Benchmark.Suite('`_.sortBy` with `property` name')
.add('Lo-Dash', function() {
lodash.sortBy(words, 'length');
.add('Lo-Dash', {
'fn': function() {
lodash.sortBy(words, 'length');
},
'teardown': 'function groupBy(){}'
})
.add('Underscore', function() {
_.sortBy(words, 'length');
.add('Underscore', {
'fn': function() {
_.sortBy(words, 'length');
},
'teardown': 'function groupBy(){}'
})

@@ -790,11 +1193,17 @@ );

Benchmark.Suite('`_.sortedIndex` with `callback`')
.add('Lo-Dash', function() {
lodash.sortedIndex(words, 'twenty-five', function(value) {
return wordToNumber[value];
});
.add('Lo-Dash', {
'fn': function() {
lodash.sortedIndex(words, 'twenty-five', function(value) {
return wordToNumber[value];
});
},
'teardown': 'function groupBy(){}'
})
.add('Underscore', function() {
_.sortedIndex(words, 'twenty-five', function(value) {
return wordToNumber[value];
});
.add('Underscore', {
'fn': function() {
_.sortedIndex(words, 'twenty-five', function(value) {
return wordToNumber[value];
});
},
'teardown': 'function groupBy(){}'
})

@@ -807,7 +1216,13 @@ );

Benchmark.Suite('`_.template` without "evaluate" delimiters (slow path)')
.add('Lo-Dash', function() {
lodash.template(tpl, tplData);
.add('Lo-Dash', {
'fn': function() {
lodash.template(tpl, tplData);
},
'teardown': 'function template(){}'
})
.add('Underscore', function() {
_.template(tpl, tplData);
.add('Underscore', {
'fn': function() {
_.template(tpl, tplData);
},
'teardown': 'function template(){}'
})

@@ -818,7 +1233,13 @@ );

Benchmark.Suite('`_.template` with "evaluate" delimiters (slow path)')
.add('Lo-Dash', function() {
lodash.template(tplWithEvaluate, tplData);
.add('Lo-Dash', {
'fn': function() {
lodash.template(tplWithEvaluate, tplData);
},
'teardown': 'function template(){}'
})
.add('Underscore', function() {
_.template(tplWithEvaluate, tplData);
.add('Underscore', {
'fn': function() {
_.template(tplWithEvaluate, tplData);
},
'teardown': 'function template(){}'
})

@@ -829,7 +1250,13 @@ );

Benchmark.Suite('compiled template without "evaluate" delimiters')
.add('Lo-Dash', function() {
lodashTpl(tplData);
.add('Lo-Dash', {
'fn': function() {
lodashTpl(tplData);
},
'teardown': 'function template(){}'
})
.add('Underscore', function() {
_tpl(tplData);
.add('Underscore', {
'fn': function() {
_tpl(tplData);
},
'teardown': 'function template(){}'
})

@@ -840,7 +1267,13 @@ );

Benchmark.Suite('compiled template with "evaluate" delimiters')
.add('Lo-Dash', function() {
lodashTplWithEvaluate(tplData);
.add('Lo-Dash', {
'fn': function() {
lodashTplWithEvaluate(tplData);
},
'teardown': 'function template(){}'
})
.add('Underscore', function() {
_tplWithEvaluate(tplData);
.add('Underscore', {
'fn': function() {
_tplWithEvaluate(tplData);
},
'teardown': 'function template(){}'
})

@@ -851,7 +1284,13 @@ );

Benchmark.Suite('compiled template without a with-statement or "evaluate" delimiters')
.add('Lo-Dash', function() {
lodashTplVerbose(tplData);
.add('Lo-Dash', {
'fn': function() {
lodashTplVerbose(tplData);
},
'teardown': 'function template(){}'
})
.add('Underscore', function() {
_tplVerbose(tplData);
.add('Underscore', {
'fn': function() {
_tplVerbose(tplData);
},
'teardown': 'function template(){}'
})

@@ -862,7 +1301,13 @@ );

Benchmark.Suite('compiled template without a with-statement using "evaluate" delimiters')
.add('Lo-Dash', function() {
lodashTplVerboseWithEvaluate(tplData);
.add('Lo-Dash', {
'fn': function() {
lodashTplVerboseWithEvaluate(tplData);
},
'teardown': 'function template(){}'
})
.add('Underscore', function() {
_tplVerboseWithEvaluate(tplData);
.add('Underscore', {
'fn': function() {
_tplVerboseWithEvaluate(tplData);
},
'teardown': 'function template(){}'
})

@@ -931,2 +1376,50 @@ );

suites.push(
Benchmark.Suite('`_.union` iterating an array of 25 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.union(twentyFiveValues, twentyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.union(twentyFiveValues, twentyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.union` iterating an array of 50 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.union(fiftyValues, fiftyValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.union(fiftyValues, fiftyValues2);
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.union` iterating an array of 75 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.union(seventyFiveValues, seventyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.union(seventyFiveValues, seventyFiveValues2);
},
'teardown': 'function multiArrays(){}'
})
);
/*--------------------------------------------------------------------------*/

@@ -972,9 +1465,72 @@

suites.push(
Benchmark.Suite('`_.without`')
.add('Lo-Dash', function() {
lodash.without(numbers, 9, 12, 14, 15);
})
.add('Underscore', function() {
_.without(numbers, 9, 12, 14, 15);
})
);
suites.push(
Benchmark.Suite('`_.without` iterating an array of 25 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.without.apply(lodash, [twentyFiveValues].concat(twentyFiveValues2));
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.without.apply(_, [twentyFiveValues].concat(twentyFiveValues2));
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.without` iterating an array of 50 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.without.apply(lodash, [fiftyValues].concat(fiftyValues2));
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.without.apply(_, [fiftyValues].concat(fiftyValues2));
},
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.without` iterating an array of 75 elements')
.add('Lo-Dash', {
'fn': function() {
lodash.without.apply(lodash, [seventyFiveValues].concat(seventyFiveValues2));
},
'teardown': 'function multiArrays(){}'
})
.add('Underscore', {
'fn': function() {
_.without.apply(_, [seventyFiveValues].concat(seventyFiveValues2));
},
'teardown': 'function multiArrays(){}'
})
);
/*--------------------------------------------------------------------------*/
if (Benchmark.platform + '') {
log(Benchmark.platform + '');
}
// start suites
log('\nSit back and relax, this may take a while.');
suites[0].run();
// in the browser, expose `run` to be called later
if (window.document) {
window.run = run;
} else {
run();
}
}(typeof global == 'object' && global || this));

@@ -1,4 +0,4 @@

# Lo-Dash <sup>v0.4.1</sup>
# Lo-Dash <sup>v0.4.2</sup>
A drop-in replacement for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), that delivers [performance improvements](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#closed-underscorejs-issues), and [additional features](https://github.com/bestiejs/lodash#features).
A drop-in replacement<sup>[*](https://github.com/bestiejs/lodash/wiki/Drop-in-Disclaimer)</sup> for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), that delivers [performance improvements](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#closed-underscorejs-issues), and [additional features](https://github.com/bestiejs/lodash#features).

@@ -9,5 +9,5 @@ Lo-Dash’s performance is gained by avoiding slower native methods, instead opting for simplified non-ES5 compliant methods optimized for common usage, and by leveraging function compilation to reduce the number of overall function calls.

* [Development source](https://raw.github.com/bestiejs/lodash/v0.4.1/lodash.js)
* [Production source](https://raw.github.com/bestiejs/lodash/v0.4.1/lodash.min.js)
* CDN copies of ≤ [v0.3.2](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.3.2/lodash.min.js) are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/)
* [Development source](https://raw.github.com/bestiejs/lodash/v0.4.2/lodash.js)
* [Production source](https://raw.github.com/bestiejs/lodash/v0.4.2/lodash.min.js)
* CDN copies of ≤ [v0.4.1](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.4.1/lodash.min.js) are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/)
* For optimal performance, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need

@@ -70,2 +70,7 @@

* Strict builds, with `_.bindAll`, `_.extend`, and `_.defaults` in [strict mode](http://es5.github.com/#C), may be created using the `strict` modifier argument.
~~~ bash
lodash strict
~~~
Custom builds may be created in three ways:

@@ -80,19 +85,19 @@

2. Use the `include` argument to pass the names of methods to include in the build.
2. Use the `exclude` argument to pass the names of methods to exclude from the build.
~~~ bash
lodash include=each,filter,map
lodash include="each, filter, map"
lodash exclude=union,uniq,zip
lodash exclude="union, uniq, zip"
~~~
3. Use the `exclude` argument to pass the names of methods to exclude from the build.
3. Use the `include` argument to pass the names of methods to include in the build.
~~~ bash
lodash exclude=union,uniq,zip
lodash exclude="union, uniq, zip"
lodash include=each,filter,map
lodash include="each, filter, map"
~~~
All arguments, except `include` with `exclude` and `mobile` with `legacy`, may be combined.
All arguments, except `exclude` with `include` and `legacy` with `mobile`, may be combined.
~~~ bash
lodash backbone mobile category=functions include=pick,uniq
lodash backbone legacy category=utilities exclude=first,last
lodash backbone mobile strict category=functions include=pick,uniq
~~~

@@ -152,25 +157,25 @@

* Allow iteration of objects with a `length` property [[#148](https://github.com/documentcloud/underscore/issues/148), [#154](https://github.com/documentcloud/underscore/issues/154), [#252](https://github.com/documentcloud/underscore/issues/252), [#448](https://github.com/documentcloud/underscore/issues/448), [#659](https://github.com/documentcloud/underscore/issues/659), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L306-312)]
* Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L257-263), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L607-621), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L863-866)]
* Ensure *"Arrays"* methods allow falsey `array` arguments [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L931-970)]
* Ensure *"Collections"* methods allow string `collection` arguments [[#247](https://github.com/documentcloud/underscore/issues/247), [#276](https://github.com/documentcloud/underscore/issues/276), [#561](https://github.com/documentcloud/underscore/pull/561), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L265-283), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L623-640), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L868-871)]
* Ensure templates compiled with errors are inspectable [[#666](https://github.com/documentcloud/underscore/issues/666), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L737-744)]
* Fix cross-browser object iteration bugs [[#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L195-207), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L317-342), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L438-449), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L457-459), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L477-497), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L667-669)]
* Allow iteration of objects with a `length` property [[#148](https://github.com/documentcloud/underscore/issues/148), [#154](https://github.com/documentcloud/underscore/issues/154), [#252](https://github.com/documentcloud/underscore/issues/252), [#448](https://github.com/documentcloud/underscore/issues/448), [#659](https://github.com/documentcloud/underscore/issues/659), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L364-370)]
* Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L315-321), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L665-679), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L921-924)]
* Ensure *"Arrays"* methods allow falsey `array` arguments [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L989-1027)]
* Ensure *"Collections"* methods allow string `collection` arguments [[#247](https://github.com/documentcloud/underscore/issues/247), [#276](https://github.com/documentcloud/underscore/issues/276), [#561](https://github.com/documentcloud/underscore/pull/561), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L148-157), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L323-341), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L681-698), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L926-929)]
* Ensure templates compiled with errors are inspectable [[#666](https://github.com/documentcloud/underscore/issues/666), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L795-802)]
* Fix cross-browser object iteration bugs [[#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L224-236), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L375-400), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L496-507), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L515-517), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L535-555), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L725-727)]
* Handle arrays with `undefined` values correctly in IE < 9 [[#601](https://github.com/documentcloud/underscore/issues/601)]
* Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L86-92)]
* Register as an AMD module, but still export to global [[#431](https://github.com/documentcloud/underscore/pull/431), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L70-84)]
* `_(…)` should return passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L104-107)]
* `_.contains` should work with strings [[#667](https://github.com/documentcloud/underscore/pull/667), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L138-147)]
* `_.escape` should return an empty string when passed `null` or `undefined` [[#407](https://github.com/documentcloud/underscore/issues/427), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L176-179)]
* `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L252-255)]
* `_.groupBy` should add values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L357-364)]
* `_isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L467-469)]
* `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L591-605)]
* `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L650-652)]
* `_.size` shouldn't error on falsey values [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L654-661)]
* `_.size` should work with `arguments` objects cross-browser [[#653](https://github.com/documentcloud/underscore/issues/653), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L663-665)]
* `_.sortedIndex` should support arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L707-716)]
* `_.template` should not augment the `options` object [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L731-735)]
* `_.throttle` should work when called in a tight loop [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L814-824)]
* `_.zipObject` should accept less than two arguments [[test](https://github.com/bestiejs/lodash/blob/v0.4.1/test/test.js#L893-895)]
* Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L96-102)]
* Register as an AMD module, but still export to global [[#431](https://github.com/documentcloud/underscore/pull/431), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L80-94)]
* `_(…)` should return passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L114-117)]
* `_.contains` should work with strings [[#667](https://github.com/documentcloud/underscore/pull/667), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L148-157)]
* `_.escape` should return an empty string when passed `null` or `undefined` [[#407](https://github.com/documentcloud/underscore/issues/427), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L205-208)]
* `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L310-313)]
* `_.groupBy` should add values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L415-422)]
* `_isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L525-527)]
* `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L649-663)]
* `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L708-710)]
* `_.size` shouldn't error on falsey values [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L712-719)]
* `_.size` should work with `arguments` objects cross-browser [[#653](https://github.com/documentcloud/underscore/issues/653), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L721-723)]
* `_.sortedIndex` should support arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L765-774)]
* `_.template` should not augment the `options` object [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L789-793)]
* `_.throttle` should work when called in a loop [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L872-882)]
* `_.zipObject` should accept less than two arguments [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L951-953)]

@@ -240,2 +245,9 @@ ## Optimized methods <sup>(50+)</sup>

### <sup>v0.4.2</sup>
* Added `strict` build
* Ensured `_.bindAll`, `_.extend`, and `_.defaults` avoid strict mode errors when attempting to augment read-only properties
* Optimized the iteration of large arrays in `_.difference`, `_.intersection`, and `_.without`
* Fixed build bugs related to removing variables
### <sup>v0.4.1</sup>

@@ -242,0 +254,0 @@

@@ -7,2 +7,8 @@ ;(function(window, undefined) {

/** The `platform` object to check */
var platform =
window.platform ||
load('../vendor/platform.js/platform.js') ||
window.platform;
/** The unit testing framework */

@@ -12,3 +18,3 @@ var QUnit =

window.setTimeout || (window.addEventListener = window.setTimeout = / /),
window.QUnit = load('../vendor/qunit/qunit/qunit.js') || window.QUnit,
window.QUnit = load('../vendor/qunit/qunit/qunit' + (platform.name == 'Narwhal' ? '-1.8.0' : '') + '.js') || window.QUnit,
load('../vendor/qunit-clib/qunit-clib.js'),

@@ -26,2 +32,5 @@ (window.addEventListener || 0).test && delete window.addEventListener,

/** Shortcut used to make object properties immutable */
var freeze = Object.freeze;
/** Shortcut used to convert array-like objects to arrays */

@@ -58,5 +67,6 @@ var slice = [].slice;

* @private
* @param {Number} count The number of tests to skip.
* @param {Number} [count=1] The number of tests to skip.
*/
function skipTest(count) {
count || (count = 1);
while (count--) {

@@ -78,3 +88,3 @@ ok(true, 'test skipped');

} else {
skipTest(1)
skipTest()
}

@@ -87,3 +97,3 @@ });

} else {
skipTest(1)
skipTest()
}

@@ -96,3 +106,3 @@ });

} else {
skipTest(1);
skipTest();
}

@@ -172,2 +182,21 @@ });

QUnit.module('lodash.difference');
(function() {
test('should work correctly when using `cachedContains`', function() {
var array1 = _.range(27),
array2 = array1.slice(),
a = {},
b = {},
c = {};
array1.push(a, b, c);
array2.push(b, c, a);
deepEqual(_.difference(array1, array2), []);
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.escape');

@@ -220,2 +249,31 @@

_.each(['bindAll', 'defaults', 'extend'], function(methodName) {
var func = _[methodName];
QUnit.module('lodash.' + methodName + ' strict mode checks');
test('should not throw strict mode errors', function() {
var object = { 'a': null, 'b': function(){} },
pass = true;
if (freeze) {
freeze(object);
try {
if (methodName == 'bindAll') {
func(object);
} else {
func(object, { 'a': 1 });
}
} catch(e) {
pass = false;
}
ok(pass);
}
else {
skipTest();
}
});
});
/*--------------------------------------------------------------------------*/
QUnit.module('lodash.find');

@@ -222,0 +280,0 @@

@@ -8,2 +8,3 @@ /*!

;(function(global) {
'use strict';

@@ -28,3 +29,4 @@ /** Add `console.log()` support for Narwhal, Rhino, and RingoJS */

/** Used by timer methods */
var timer,
var doneCalled,
timer,
counter = 0,

@@ -154,22 +156,22 @@ ids = {};

function done(details) {
// stop `asyncTest()` from erroneously calling `done()` twice in environments w/o timeouts
if (!QUnit.doneCalled) {
console.log(hr);
console.log(' PASS: ' + details.passed + ' FAIL: ' + details.failed + ' TOTAL: ' + details.total);
console.log(' Finished in ' + details.runtime + ' milliseconds.');
console.log(hr);
// stop `asyncTest()` from erroneously calling `done()` twice in
// environments w/o timeouts
if (doneCalled) {
return;
}
doneCalled = true;
console.log(hr);
console.log(' PASS: ' + details.passed + ' FAIL: ' + details.failed + ' TOTAL: ' + details.total);
console.log(' Finished in ' + details.runtime + ' milliseconds.');
console.log(hr);
// exit out of Rhino
try {
quit();
} catch(e) { }
// exit out of Rhino
try {
quit();
} catch(e) { }
// exit out of Node.js
try {
process.exit();
} catch(e) { }
// prevent multiple calls to `done()`
QUnit.doneCalled = true;
}
// exit out of Node.js
try {
process.exit();
} catch(e) { }
}

@@ -187,9 +189,10 @@

result = details.result,
type = typeof expected != 'undefined' ? 'EQ' : 'OK',
assertion = [
result ? 'PASS' : 'FAIL',
type,
details.message || 'ok'
];
type = typeof expected != 'undefined' ? 'EQ' : 'OK';
var assertion = [
result ? 'PASS' : 'FAIL',
type,
details.message || 'ok'
];
if (!result && type == 'EQ') {

@@ -222,3 +225,3 @@ assertion.push('Expected: ' + expected + ', Actual: ' + details.actual);

var parseObject = (function() {
var _parseObject = QUnit.jsDump.parsers.object;
var func = QUnit.jsDump.parsers.object;
return function(object) {

@@ -232,3 +235,3 @@ // fork to support Rhino's error objects

}
return _parseObject(object);
return func(object);
};

@@ -246,6 +249,6 @@ }());

var assertions = QUnit.config.testStats.assertions,
name = details.name;
testName = details.name;
if (details.failed > 0) {
console.log(' FAIL - '+ name);
console.log(' FAIL - '+ testName);
each(assertions, function(value) {

@@ -256,3 +259,3 @@ console.log(' ' + value);

else {
console.log(' PASS - ' + name);
console.log(' PASS - ' + testName);
}

@@ -285,4 +288,7 @@ assertions.length = 0;

'notEqual', 'notStrictEqual', 'ok', 'raises', 'same', 'start', 'stop',
'strictEqual', 'test'], function(name) {
global[name] = QUnit[name];
'strictEqual', 'test', 'throws'], function(funcName) {
var func = QUnit[funcName];
if (func) {
global[funcName] = func;
}
});

@@ -313,9 +319,9 @@

// wrap `parseObject`
// add wrapped function
QUnit.jsDump.parsers.object = parseObject;
// must call `QUnit.start()` in the test file if using QUnit < 1.3.0 with Node.js
// or any version of QUnit with Narwhal, Rhino, or RingoJS
// must call `QUnit.start()` in the test file if using QUnit < 1.3.0 with
// Node.js or any version of QUnit with Narwhal, Rhino, or RingoJS
QUnit.init();
}(typeof global == 'object' && global || this));
/**
* QUnit v1.8.0 - A JavaScript Unit Testing Framework
* QUnit v1.9.0 - A JavaScript Unit Testing Framework
*

@@ -406,2 +406,4 @@ * http://docs.jquery.com/QUnit

* Asserts rough true-ish result.
* @name ok
* @function
* @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );

@@ -441,2 +443,4 @@ */

* Prints out both actual and expected values.
* @name equal
* @function
* @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );

@@ -448,2 +452,6 @@ */

/**
* @name notEqual
* @function
*/
notEqual: function( actual, expected, message ) {

@@ -453,2 +461,6 @@ QUnit.push( expected != actual, actual, expected, message );

/**
* @name deepEqual
* @function
*/
deepEqual: function( actual, expected, message ) {

@@ -458,2 +470,6 @@ QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );

/**
* @name notDeepEqual
* @function
*/
notDeepEqual: function( actual, expected, message ) {

@@ -463,2 +479,6 @@ QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );

/**
* @name strictEqual
* @function
*/
strictEqual: function( actual, expected, message ) {

@@ -468,2 +488,6 @@ QUnit.push( expected === actual, actual, expected, message );

/**
* @name notStrictEqual
* @function
*/
notStrictEqual: function( actual, expected, message ) {

@@ -473,6 +497,7 @@ QUnit.push( expected !== actual, actual, expected, message );

raises: function( block, expected, message ) {
throws: function( block, expected, message ) {
var actual,
ok = false;
// 'expected' is optional
if ( typeof expected === "string" ) {

@@ -505,15 +530,26 @@ message = expected;

}
QUnit.push( ok, actual, null, message );
} else {
QUnit.pushFailure( message, null, 'No exception was thrown.' );
}
QUnit.push( ok, actual, null, message );
}
};
// @deprecated: Kept assertion helpers in root for backwards compatibility
/**
* @deprecate since 1.8.0
* Kept assertion helpers in root for backwards compatibility
*/
extend( QUnit, QUnit.assert );
/**
* @deprecated: Kept for backwards compatibility
* next step: remove entirely
* @deprecated since 1.9.0
* Kept global "raises()" for backwards compatibility
*/
QUnit.raises = QUnit.assert.throws;
/**
* @deprecated since 1.0.0, replaced with error pushes since 1.3.0
* Kept to avoid TypeErrors for undefined methods.
*/
QUnit.equals = function() {

@@ -561,3 +597,16 @@ QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" );

urlConfig: [ "noglobals", "notrycatch" ],
// add checkboxes that are persisted in the query-string
// when enabled, the id is set to `true` as a `QUnit.config` property
urlConfig: [
{
id: "noglobals",
label: "Check for Globals",
tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."
},
{
id: "notrycatch",
label: "No try-catch",
tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."
}
],

@@ -783,3 +832,3 @@ // logging callback queues

pushFailure: function( message, source ) {
pushFailure: function( message, source, actual ) {
if ( !config.current ) {

@@ -795,11 +844,19 @@ throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) );

message = escapeInnerText(message ) || "error";
message = escapeInnerText( message ) || "error";
message = "<span class='test-message'>" + message + "</span>";
output = message;
output += "<table>";
if ( actual ) {
output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeInnerText( actual ) + "</pre></td></tr>";
}
if ( source ) {
details.source = source;
output += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>";
output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>";
}
output += "</table>";
runLoggingCallbacks( "log", QUnit, details );

@@ -874,3 +931,3 @@

// Initialize the config, saving the execution queue
var banner, filter, i, label, len, main, ol, toolbar, userAgent, val,
var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, urlConfigCheckboxes,
urlConfigHtml = "",

@@ -888,4 +945,11 @@ oldconfig = extend( {}, config );

val = config.urlConfig[i];
config[val] = QUnit.urlParams[val];
urlConfigHtml += "<label><input name='" + val + "' type='checkbox'" + ( config[val] ? " checked='checked'" : "" ) + ">" + val + "</label>";
if ( typeof val === "string" ) {
val = {
id: val,
label: val,
tooltip: "[no tooltip available]"
};
}
config[ val.id ] = QUnit.urlParams[ val.id ];
urlConfigHtml += "<input id='qunit-urlconfig-" + val.id + "' name='" + val.id + "' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) + " title='" + val.tooltip + "'><label for='qunit-urlconfig-" + val.id + "' title='" + val.tooltip + "'>" + val.label + "</label>";
}

@@ -902,8 +966,3 @@

if ( banner ) {
banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined }) + "'>" + banner.innerHTML + "</a> " + urlConfigHtml;
addEvent( banner, "change", function( event ) {
var params = {};
params[ event.target.name ] = event.target.checked ? true : undefined;
window.location = QUnit.url( params );
});
banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) + "'>" + banner.innerHTML + "</a> ";
}

@@ -949,4 +1008,14 @@

label.setAttribute( "for", "qunit-filter-pass" );
label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." );
label.innerHTML = "Hide passed tests";
toolbar.appendChild( label );
urlConfigCheckboxes = document.createElement( 'span' );
urlConfigCheckboxes.innerHTML = urlConfigHtml;
addEvent( urlConfigCheckboxes, "change", function( event ) {
var params = {};
params[ event.target.name ] = event.target.checked ? true : undefined;
window.location = QUnit.url( params );
});
toolbar.appendChild( urlConfigCheckboxes );
}

@@ -1070,3 +1139,3 @@

filter = config.filter && config.filter.toLowerCase(),
module = config.module,
module = config.module && config.module.toLowerCase(),
fullName = (test.module + ": " + test.testName).toLowerCase();

@@ -1078,3 +1147,3 @@

if ( module && test.module !== module ) {
if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) {
return false;

@@ -1081,0 +1150,0 @@ }

@@ -44,6 +44,7 @@ [QUnit](http://docs.jquery.com/QUnit) - A JavaScript Unit Testing framework.

Install git-extras and run `git changelog` to update History.md.
Update qunit/qunit.js|css to the release version, commit and tag, update them
again to the next version, commit and push commits and tags.
Update qunit/qunit.js|css and package.json to the release version, commit and
tag, update them again to the next version, commit and push commits and tags
(`git push --tags origin master`).
Put the 'v' in front of the tag (unlike the 1.1.0 release). Clean up the changelog,
removing merge commits or whitespace cleanups.
Put the 'v' in front of the tag, e.g. `v1.8.0`. Clean up the changelog, removing merge commits
or whitespace cleanups.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc