From 2890b92b21c3dad7b7a1cd64f710109b28c7b187 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 18 Aug 2012 03:37:43 -0700 Subject: [PATCH 01/19] Tweak to `_.bind` unit test for Narwhal. Former-commit-id: 5df60a9d1e46b09253151ab39281c5af0c48544f --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index d28b41a32e..e8ae615aca 100644 --- a/test/test.js +++ b/test/test.js @@ -145,7 +145,7 @@ (function() { test('should correctly append array arguments to partially applied arguments (test in IE < 9)', function() { var args, - bound = _.bind(function() { args = slice.call(arguments); }, null, 'a'); + bound = _.bind(function() { args = slice.call(arguments); }, {}, 'a'); bound(['b'], 'c'); deepEqual(args, ['a', ['b'], 'c']); From 95f07ea38a5b1dc88fbf1ec5e8cd0934f150b8b6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 18 Aug 2012 03:40:42 -0700 Subject: [PATCH 02/19] Add stable-sort note to `_.sortBy` documentation. Former-commit-id: 17b9818baa6ff72ce5762ec8b3cc01bbac8725bb --- README.md | 1 + doc/README.md | 2 +- lodash.js | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5287609941..ac8cf774fb 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ For more information check out these screencasts over Lo-Dash: * [_.indexOf](http://lodash.com/docs#indexOf) and [_.lastIndexOf](http://lodash.com/docs#lastIndexOf) accept a `fromIndex` argument * [_.merge](http://lodash.com/docs#merge) for a *"deep"* [_.extend](http://lodash.com/docs#extend) * [_.partial](http://lodash.com/docs#partial) for partial application without `this` binding + * [_.sortBy](http://lodash.com/docs#sortBy) performs a [stable](http://en.wikipedia.org/wiki/Sorting_algorithm#Stability) sort * [_.template](http://lodash.com/docs#template) utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging * [_.where](http://lodash.com/docs#where) for filtering collections by contained properties * [_.zipObject](http://lodash.com/docs#zipObject) for composing objects diff --git a/doc/README.md b/doc/README.md index a082f6ebd0..c35d931ddf 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2185,7 +2185,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(collection, callback [, thisArg])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2280 "View in source") [Ⓣ][1] -Creates a new sorted array, sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. +Creates a new array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. diff --git a/lodash.js b/lodash.js index c8ec61c168..718a1849f9 100644 --- a/lodash.js +++ b/lodash.js @@ -678,8 +678,8 @@ } /** - * Used by `sortBy` to compare transformed `collection` values, sorting them - * stabily in ascending order. + * Used by `sortBy` to compare transformed `collection` values, stable sorting + * them in ascending order. * * @private * @param {Object} a The object to compare to `b`. @@ -2253,9 +2253,9 @@ }); /** - * Creates a new sorted array, sorted in ascending order by the results of - * running each element of `collection` through a `callback`. The `callback` is - * bound to `thisArg` and invoked with 3 arguments; (value, index|key, collection). + * Creates a new array, stable sorted in ascending order by the results of + * running each element of `collection` through a `callback`. The `callback` + * is bound to `thisArg` and invoked with 3 arguments; (value, index|key, collection). * The `callback` argument may also be the name of a property to sort by (e.g. 'length'). * * @static From 07a370fd248fb5263e6b36ca128cd317bda6fac4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 18 Aug 2012 10:02:38 -0700 Subject: [PATCH 03/19] Update cdnjs link to v0.5.1 in README.md. Former-commit-id: 3c00694a949b4f30be48a898f1f2a9046b2573d1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac8cf774fb..8c1684a151 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Lo-Dash’s performance is gained by avoiding slower native methods, instead opt * [Development source](https://raw.github.com/bestiejs/lodash/v0.5.1/lodash.js) * [Production source](https://raw.github.com/bestiejs/lodash/v0.5.1/lodash.min.js) - * CDN copies of ≤ [v0.5.0](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.5.0/lodash.min.js) are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/) + * CDN copies of ≤ [v0.5.1](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.5.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 ## Dive in From 285f0bc6dd20f6e6e1870f9dd005b56759442e1f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 18 Aug 2012 20:52:31 -0700 Subject: [PATCH 04/19] Ensure isXYZ methods return boolean values and almost all methods allow falsey arguments. Former-commit-id: a842eaf2fd262bed03df4a71b560b91801b7a75f --- lodash.js | 149 +++++++++++++++++++++++++++------------------------ test/test.js | 139 ++++++++++++++++++++++++----------------------- 2 files changed, 147 insertions(+), 141 deletions(-) diff --git a/lodash.js b/lodash.js index 718a1849f9..a453812ee9 100644 --- a/lodash.js +++ b/lodash.js @@ -379,15 +379,15 @@ // iterate own properties using `Object.keys` if it's fast ' <% if (isKeysFast && useHas) { %>\n' + ' var ownIndex = -1,\n' + - ' ownProps = nativeKeys(iteratee),\n' + + ' ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n' + ' length = ownProps.length;\n\n' + ' <%= objectBranch.beforeLoop %>;\n' + ' while (++ownIndex < length) {\n' + ' index = ownProps[ownIndex];\n' + - ' if (!(skipProto && index == \'prototype\')) {\n' + - ' value = iteratee[index];\n' + - ' <%= objectBranch.inLoop %>\n' + - ' }\n' + + ' <% if (!hasDontEnumBug) { %>if (!(skipProto && index == \'prototype\')) {\n <% } %>' + + ' value = iteratee[index];\n' + + ' <%= objectBranch.inLoop %>\n' + + ' <% if (!hasDontEnumBug) { %>}\n<% } %>' + ' }' + // else using a for-in loop @@ -946,7 +946,6 @@ */ var shimKeys = createIterator({ 'args': 'object', - 'exit': 'if (!(object && objectTypes[typeof object])) throw TypeError()', 'init': '[]', 'inLoop': 'result.push(index)' }); @@ -1231,7 +1230,7 @@ * // => true */ function has(object, property) { - return hasOwnProperty.call(object, property); + return object ? hasOwnProperty.call(object, property) : false; } /** @@ -1282,7 +1281,7 @@ * // => true */ function isElement(value) { - return !!(value && value.nodeType == 1); + return value ? value.nodeType == 1 : false; } /** @@ -1547,7 +1546,7 @@ // http://es5.github.com/#x8 // and avoid a V8 bug // http://code.google.com/p/v8/issues/detail?id=2291 - return value && objectTypes[typeof value]; + return value ? objectTypes[typeof value] : false; } /** @@ -1686,12 +1685,74 @@ * // => ['one', 'two', 'three'] (order is not guaranteed) */ var keys = !nativeKeys ? shimKeys : function(object) { + var type = typeof object; + // avoid iterating over the `prototype` property - return typeof object == 'function' && propertyIsEnumerable.call(object, 'prototype') - ? shimKeys(object) - : nativeKeys(object); + if (type == 'function' && propertyIsEnumerable.call(object, 'prototype')) { + return shimKeys(object); + } + return object && objectTypes[type] + ? nativeKeys(object) + : []; }; + /** + * Merges enumerable properties of the source object(s) into the `destination` + * object. Subsequent sources will overwrite propery assignments of previous + * sources. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The destination object. + * @param {Object} [source1, source2, ...] The source objects. + * @param {Object} [indicator] Internally used to indicate that the `stack` + * argument is an array of traversed objects instead of another source object. + * @param {Array} [stack=[]] Internally used to keep track of traversed objects + * to avoid circular references. + * @returns {Object} Returns the destination object. + * @example + * + * var stooges = [ + * { 'name': 'moe' }, + * { 'name': 'larry' } + * ]; + * + * var ages = [ + * { 'age': 40 }, + * { 'age': 50 } + * ]; + * + * _.merge(stooges, ages); + * // => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] + */ + var merge = createIterator(extendIteratorOptions, { + 'args': 'object, source, indicator, stack', + 'top': + 'var destValue, found, isArr, stackLength, recursive = indicator == isPlainObject;\n' + + 'if (!recursive) stack = [];\n' + + 'for (var argsIndex = 1, argsLength = recursive ? 2 : arguments.length; argsIndex < argsLength; argsIndex++) {\n' + + ' if (iteratee = arguments[argsIndex]) {', + 'inLoop': + 'if (value && ((isArr = isArray(value)) || isPlainObject(value))) {\n' + + ' found = false; stackLength = stack.length;\n' + + ' while (stackLength--) {\n' + + ' if (found = stack[stackLength].source == value) break\n' + + ' }\n' + + ' if (found) {\n' + + ' result[index] = stack[stackLength].value\n' + + ' } else {\n' + + ' destValue = (destValue = result[index]) && isArr\n' + + ' ? (isArray(destValue) ? destValue : [])\n' + + ' : (isPlainObject(destValue) ? destValue : {});\n' + + ' stack.push({ value: destValue, source: value });\n' + + ' result[index] = callee(destValue, value, isPlainObject, stack)\n' + + ' }\n' + + '} else if (value != null) {\n' + + ' result[index] = value\n' + + '}' + }); + /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of @@ -1709,11 +1770,14 @@ * // => { 'name': 'moe', 'age': 40 } */ function pick(object) { + var result = {}; + if (!object) { + return result; + } var prop, index = 0, props = concat.apply(ArrayProto, arguments), - length = props.length, - result = {}; + length = props.length; // start `index` at `1` to skip `object` while (++index < length) { @@ -2025,63 +2089,6 @@ */ var map = createIterator(baseIteratorOptions, mapIteratorOptions); - /** - * Merges enumerable properties of the source object(s) into the `destination` - * object. Subsequent sources will overwrite propery assignments of previous - * sources. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The destination object. - * @param {Object} [source1, source2, ...] The source objects. - * @param {Object} [indicator] Internally used to indicate that the `stack` - * argument is an array of traversed objects instead of another source object. - * @param {Array} [stack=[]] Internally used to keep track of traversed objects - * to avoid circular references. - * @returns {Object} Returns the destination object. - * @example - * - * var stooges = [ - * { 'name': 'moe' }, - * { 'name': 'larry' } - * ]; - * - * var ages = [ - * { 'age': 40 }, - * { 'age': 50 } - * ]; - * - * _.merge(stooges, ages); - * // => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] - */ - var merge = createIterator(extendIteratorOptions, { - 'args': 'object, source, indicator, stack', - 'top': - 'var destValue, found, isArr, stackLength, recursive = indicator == isPlainObject;\n' + - 'if (!recursive) stack = [];\n' + - 'for (var argsIndex = 1, argsLength = recursive ? 2 : arguments.length; argsIndex < argsLength; argsIndex++) {\n' + - ' if (iteratee = arguments[argsIndex]) {', - 'inLoop': - 'if (value && ((isArr = isArray(value)) || isPlainObject(value))) {\n' + - ' found = false; stackLength = stack.length;\n' + - ' while (stackLength--) {\n' + - ' if (found = stack[stackLength].source == value) break\n' + - ' }\n' + - ' if (found) {\n' + - ' result[index] = stack[stackLength].value\n' + - ' } else {\n' + - ' destValue = (destValue = result[index]) && isArr\n' + - ' ? (isArray(destValue) ? destValue : [])\n' + - ' : (isPlainObject(destValue) ? destValue : {});\n' + - ' stack.push({ value: destValue, source: value });\n' + - ' result[index] = callee(destValue, value, isPlainObject, stack)\n' + - ' }\n' + - '} else if (value != null) {\n' + - ' result[index] = value\n' + - '}' - }); - /** * Retrieves the value of a specified property from all elements in * the `collection`. diff --git a/test/test.js b/test/test.js index e8ae615aca..9798b2bf21 100644 --- a/test/test.js +++ b/test/test.js @@ -817,6 +817,50 @@ /*--------------------------------------------------------------------------*/ + _.each([ + 'isArguments', + 'isArray', + 'isBoolean', + 'isDate', + 'isElement', + 'isEmpty', + 'isEqual', + 'isFinite', + 'isFunction', + 'isNaN', + 'isNull', + 'isNumber', + 'isObject', + 'isRegExp', + 'isString', + 'isUndefined' + ], function(methodName) { + var func = _[methodName]; + QUnit.module('lodash.' + methodName + ' result'); + + test('should return a boolean', function() { + var expected = 'boolean'; + + equal(typeof func(arguments), expected); + equal(typeof func([]), expected); + equal(typeof func(true), expected); + equal(typeof func(false), expected); + equal(typeof func(new Date), expected); + equal(typeof func(window.document && document.body), expected); + equal(typeof func({}), expected); + equal(typeof func(undefined), expected); + equal(typeof func(Infinity), expected); + equal(typeof func(_), expected); + equal(typeof func(NaN), expected); + equal(typeof func(null), expected); + equal(typeof func(0), expected); + equal(typeof func({ 'a': 1 }), expected); + equal(typeof func('a'), expected); + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.keys'); (function() { @@ -1489,88 +1533,43 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash "Arrays" methods'); - - (function() { - test('should allow a falsey `array` argument', function() { - _.each([ - 'compact', - 'difference', - 'first', - 'flatten', - 'groupBy', - 'indexOf', - 'initial', - 'intersection', - 'last', - 'lastIndexOf', - 'max', - 'min', - 'range', - 'rest', - 'shuffle', - 'sortBy', - 'sortedIndex', - 'union', - 'uniq', - 'without', - 'zip', - 'zipObject' - ], function(methodName) { - var func = _[methodName], - pass = true; - - _.each(falsey, function(value, index) { - try { - index ? func() : func(value); - } catch(e) { - pass = false; - } - }); - - ok(pass, methodName + ' allows a falsey `array` argument'); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('lodash "Collections" methods'); + QUnit.module('lodash methods'); (function() { - test('should allow a falsey `collection` argument', function() { - _.each([ - 'contains', - 'every', - 'filter', - 'find', - 'forEach', - 'invoke', - 'map', - 'pluck', - 'reduce', - 'reduceRight', - 'reject', - 'some', - 'toArray' - ], function(methodName) { + test('should allow a falsey arguments', function() { + var funcs = _.without.apply(_, [_.functions(_)].concat([ + '_iteratorTemplate', + '_shimKeys', + 'after', + 'bind', + 'bindAll', + 'compose', + 'debounce', + 'defer', + 'delay', + 'functions', + 'memoize', + 'once', + 'partial', + 'tap', + 'template', + 'throttle', + 'wrap' + ])); + + _.each(funcs, function(methodName) { var func = _[methodName], - identity = _.identity, pass = true; _.each(falsey, function(value, index) { try { - if (/^(?:contains|toArray)$/.test(methodName)) { - index ? func() : func(value); - } else if (index) { - func(value, identity); - } + index ? func(value) : func(); } catch(e) { pass = false; } }); - ok(pass, methodName + ' allows a falsey `collection` argument'); + ok(pass, methodName + ' allows a falsey arguments'); }); }); }()); From 0c25dd44b32f243e14d30b3668391e2322e33b8c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 18 Aug 2012 21:41:29 -0700 Subject: [PATCH 05/19] Ensure `_.isElement` uses strict equality in its duck type check. Former-commit-id: 6348026ebdc219ef1df9926aca1d8df66e472de9 --- lodash.js | 2 +- test/test.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index a453812ee9..a06b6af0f3 100644 --- a/lodash.js +++ b/lodash.js @@ -1281,7 +1281,7 @@ * // => true */ function isElement(value) { - return value ? value.nodeType == 1 : false; + return value ? value.nodeType === 1 : false; } /** diff --git a/test/test.js b/test/test.js index 9798b2bf21..7f156a0f32 100644 --- a/test/test.js +++ b/test/test.js @@ -699,6 +699,23 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.isElement'); + + (function() { + test('should use strict equality in its duck type check', function() { + var element = window.document ? document.body : { 'nodeType': 1 }; + equal(_.isElement(element), true); + + equal(_.isElement({ 'nodeType': new Number(1) }), false); + equal(_.isElement({ 'nodeType': true }), false); + equal(_.isElement({ 'nodeType': [1] }), false); + equal(_.isElement({ 'nodeType': '1' }), false); + equal(_.isElement({ 'nodeType': '001' }), false); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.isEmpty'); (function() { From 985f4aafca73f5bb6584a03ae95fef1a69f947c3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 18 Aug 2012 21:44:35 -0700 Subject: [PATCH 06/19] Update minified build and rebuild docs. Former-commit-id: 0c2c5769a94c0591359fcc7d0ae55ccfe975c38b --- doc/README.md | 176 +++++++++++++++++++++++++------------------------- lodash.min.js | 69 ++++++++++---------- 2 files changed, 123 insertions(+), 122 deletions(-) diff --git a/doc/README.md b/doc/README.md index c35d931ddf..48e4c1a6a3 100644 --- a/doc/README.md +++ b/doc/README.md @@ -152,7 +152,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4046 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4053 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -164,7 +164,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -192,7 +192,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3199 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3206 "View in source") [Ⓣ][1] Creates a new function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. Lazy defined methods may be bound by passing the object they are bound to as `func` and the method name as `thisArg`. @@ -243,7 +243,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3269 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3276 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -274,7 +274,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3971 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3978 "View in source") [Ⓣ][1] Wraps the value in a `lodash` wrapper object. @@ -308,7 +308,7 @@ var youngest = _.chain(stooges) ### `_.clone(value, deep [, guard, stack=[]], thorough)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L994 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L993 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned otherwise they will be assigned by reference. If a value has a `clone` method it will be used to perform the clone. Functions, DOM nodes, `arguments` objects, and objects created by constructors other than `Object` are **not** cloned unless they have a custom `clone` method. @@ -350,7 +350,7 @@ shallow[0] === stooges[0]; ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2384 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2391 "View in source") [Ⓣ][1] Creates a new array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -374,7 +374,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3314 "View in source") [Ⓣ][1] Creates a new function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. @@ -401,7 +401,7 @@ welcome('moe'); ### `_.contains(collection, target)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1811 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1875 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. @@ -432,7 +432,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1847 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1911 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -464,7 +464,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3340 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3347 "View in source") [Ⓣ][1] Creates a new function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -490,7 +490,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1094 "View in source") [Ⓣ][1] Assigns enumerable properties of the default object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -516,7 +516,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3405 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3412 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -541,7 +541,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3385 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3392 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -568,7 +568,7 @@ _.delay(log, 1000, 'logged later'); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2416 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2423 "View in source") [Ⓣ][1] Creates a new array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -593,7 +593,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.drop(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1114 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. @@ -618,7 +618,7 @@ _.drop({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'userid'); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3602 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3609 "View in source") [Ⓣ][1] Escapes a string for inclusion in HTML, replacing `&`, `<`, `"`, and `'` characters. @@ -642,7 +642,7 @@ _.escape('Moe, Larry & Curly'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1867 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1931 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -668,7 +668,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1139 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1138 "View in source") [Ⓣ][1] Assigns enumerable properties of the source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -693,7 +693,7 @@ _.extend({ 'name': 'moe' }, { 'age': 40 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1887 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1951 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -719,7 +719,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1908 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1972 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -745,7 +745,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.first(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2453 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2460 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -771,7 +771,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2477 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2484 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -799,7 +799,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.forEach(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1935 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1999 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -828,7 +828,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.forIn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1169 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1168 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -864,7 +864,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1193 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1192 "View in source") [Ⓣ][1] Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -892,7 +892,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1210 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1209 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -916,7 +916,7 @@ _.functions(_); ### `_.groupBy(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1963 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2027 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -948,7 +948,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1232 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -973,7 +973,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3622 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3629 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -998,7 +998,7 @@ moe === _.identity(moe); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2521 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2528 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster binary search. @@ -1030,7 +1030,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2561 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2568 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -1056,7 +1056,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2583 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2590 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -1080,7 +1080,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1991 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2055 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1163,7 +1163,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1250 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1249 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -1187,7 +1187,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1267 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -1211,7 +1211,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -1235,7 +1235,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -1265,7 +1265,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, stack=[]], thorough)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1351 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1350 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If a value has an `isEqual` method it will be used to perform the comparison. @@ -1298,7 +1298,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1524 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1523 "View in source") [Ⓣ][1] Checks if `value` is a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and other values. See http://es5.github.com/#x15.1.2.5. @@ -1352,7 +1352,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1578 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return true for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. @@ -1385,7 +1385,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1602 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1601 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -1412,7 +1412,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1619 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1618 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -1436,7 +1436,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1545 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1544 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -1463,7 +1463,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1636 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1635 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -1487,7 +1487,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1653 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1652 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -1511,7 +1511,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1670 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -1535,7 +1535,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1688 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1687 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -1559,7 +1559,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.last(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2631 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the lasy `n` elementsvof the `array`. @@ -1585,7 +1585,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2650 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2657 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. @@ -1614,7 +1614,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2026 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2090 "View in source") [Ⓣ][1] Creates a new array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -1643,7 +1643,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2690 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2697 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1675,7 +1675,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3428 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3435 "View in source") [Ⓣ][1] Creates a new function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. @@ -1701,7 +1701,7 @@ var fibonacci = _.memoize(function(n) { ### `_.merge(object [, source1, source2, ..., indicator, stack=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2058 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1729 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1738,7 +1738,7 @@ _.merge(stooges, ages); ### `_.min(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2740 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2747 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1764,7 +1764,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3648 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3655 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1794,7 +1794,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3679 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3686 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1814,7 +1814,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3454 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3461 "View in source") [Ⓣ][1] Creates a new function that is restricted to one execution. Repeat calls to the function will return the value of the first call. @@ -1840,7 +1840,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3489 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3496 "View in source") [Ⓣ][1] Creates a new function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar `bind`, except it does **not** alter the `this` binding. @@ -1867,7 +1867,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1711 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1772 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. @@ -1892,7 +1892,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2106 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2113 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1923,7 +1923,7 @@ _.pluck(stooges, 'name'); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2801 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2808 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -1961,7 +1961,7 @@ _.range(0); ### `_.reduce(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2141 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1988,7 +1988,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2178 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -2016,7 +2016,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2227 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2234 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -2042,7 +2042,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.rest(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2840 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2847 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -2068,7 +2068,7 @@ _.rest([3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3711 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3718 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2103,7 +2103,7 @@ _.result(object, 'stuff'); ### `_.shuffle(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2861 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2868 "View in source") [Ⓣ][1] Creates a new array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -2127,7 +2127,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1750 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1814 "View in source") [Ⓣ][1] Gets the size of `value` by returning `value.length` if `value` is an array, string, or `arguments` object. If `value` is an object, size is determined by returning the number of own enumerable properties it has. @@ -2157,7 +2157,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2250 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2257 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -2183,7 +2183,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2280 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2287 "View in source") [Ⓣ][1] Creates a new array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -2215,7 +2215,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2913 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2920 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with `1` argument; *(value)*. @@ -2256,7 +2256,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) { ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3998 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4005 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -2286,7 +2286,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3774 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3781 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: For Chrome extensions use the `lodash csp` build and see http://code.google.com/chrome/extensions/trunk/sandboxingEval.html @@ -2345,7 +2345,7 @@ _.template('Using a with-statement: <%= data.answer %>', { 'answer': 'no' }, { ' ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3525 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3532 "View in source") [Ⓣ][1] Creates a new function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2370,7 +2370,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3914 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3921 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*. @@ -2396,7 +2396,7 @@ _.times(3, function() { this.grantWish(); }, genie); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2317 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2324 "View in source") [Ⓣ][1] Converts the `collection`, into an array. Useful for converting the `arguments` object. @@ -2420,7 +2420,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2954 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2961 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -2444,7 +2444,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2998 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3005 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -2480,7 +2480,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3948 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2504,7 +2504,7 @@ _.uniqueId('contact_'); ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1781 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1845 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2528,7 +2528,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2354 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2361 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -2559,7 +2559,7 @@ _.where(stooges, { 'age': 40 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3054 "View in source") [Ⓣ][1] Creates a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2584,7 +2584,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3576 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3583 "View in source") [Ⓣ][1] Creates a new function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the new function are appended to those passed to the `wrapper` function. @@ -2613,7 +2613,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3087 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -2637,7 +2637,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3109 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3116 "View in source") [Ⓣ][1] Creates an object composed from an array of `keys` and an array of `values`. @@ -2669,7 +2669,7 @@ _.zipObject(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4016 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4023 "View in source") [Ⓣ][1] Enables method chaining on the wrapper object. @@ -2690,7 +2690,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4033 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4040 "View in source") [Ⓣ][1] Extracts the wrapped value. diff --git a/lodash.min.js b/lodash.min.js index 0a7d4c0387..b10a0bb374 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -4,37 +4,38 @@ */ ;(function(e,t){"use strict";function s(e){return new o(e)}function o(e){if(e&&e._wrapped)return e;this._wrapped=e}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||30),s=i?{}:e;if(i)for(var o=t-1;++on;n++)t+="g='"+u.p[n]+"';if(","constructor"==u.p[n]&&(t+="!(d&&d.prototype===h)&&"),t+="e.call(h,g)){y=h[g];"+u.m.i+"}"}if(u.c||u.n)t+="}"}return t+=u.e+";return s",Function("D,E,F,I,c,K,e,f,N,P,R,T,U,i,X,Y,k,p,u,v,x","var G=function("+e+"){"+t+"};return G")(Ht,I,M,f,st,Zt,ot,_,C,b,Jt,w,p,d,wt,Ft,dt,at,ft,St,lt)}function f(e,n){var r=e.b,i=n.b,e=e.a,n=n.a;return e===t?1:n===t?-1:en?1:r";var n=it.length;return it[n]="'+__e("+t+")+'",rt+n}function g(e,t,n,r){return e=it.length,t?it[e]="'+__e("+ -t+")+'":r?it[e]="';"+r+";__p+='":n&&(it[e]="'+((__t=("+n+"))==null?'':__t)+'"),rt+e}function y(e,t){if(V.test(t))return"";var n=it.length;return it[n]="'+((__t=("+t+"))==null?'':__t)+'",rt+n}function b(e){return lt.call(e)==vt}function w(e){return"function"==typeof e}function E(e,t,s,o,u){if(e==r)return e;s&&(t=i),u||(u={d:r}),u.d==r&&(u.d=!(!q.clone&&!U.clone&&!z.clone));if(((s=Ft[typeof e])||u.d)&&e.clone&&w(e.clone))return u.d=r,e.clone(t);if(s){var a=lt.call(e);if(!Bt[a]||Lt&&b(e)) -return e;var f=a==mt,s=f||(a==wt?p(e,n):s)}if(!s||!t)return s?f?ft.call(e):Yt({},e):e;s=e.constructor;switch(a){case gt:return new s(e==n);case yt:return new s(+e);case bt:case St:return new s(e);case Et:return s(e.source,Q.exec(e))}o||(o=[]);for(a=o.length;a--;)if(o[a].c==e)return o[a].d;var a=e.length,l=f?s(a):{};o.push({d:l,c:e});if(f)for(f=-1;++f++u;)if(c=nt[u],ot.call(e,c)&&(!ot.call(t,c)||!S(e[c],t[c],s,o)))return i;return n}function x(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=d(t,r));if(-1>>0){var o=Ot&<.call(e)==St?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=rn(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function T(e,t,n){if(e)return t==r||n?e[0]:ft.call(e,0,t)}function N(e,t){var n=[];if(!e)return n;for(var r,i=-1,s=e.length;++in?Math.max(0,i+n):n)-1}for(;++ri&&(i=e[s]);return i}for(n&&(t=d(t,n));++sr&&(r=n,i=e[s]);return i}function L(e,t,n){return e?ft.call(e,t==r||n?1:t):[]}function A(e,t,n,r){if(!e)return 0 -;var i=0,s=e.length;if(n){r&&(n=M(n,r));for(t=n(t);i>>1,n(e[r])>>1,e[r]C(a,r))a.push(r),s.push(e[o]);return s}function M(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length?s.concat(ft.call(o)):s),this instanceof n?(v.prototype=e -.prototype,u=new v,(o=e.apply(u,o))&&Ft[typeof o]?o:u):e.apply(u,o)}var r,i=w(e);if(i){if(Dt||ct&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,$=/\b__p\+='';/g,J=/\b(__p\+=)''\+/g,K=/(__e\(.*?\)|\b__t\))\+'';/g,Q=/\w*$/,G=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,Y=RegExp("^"+(R.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Z=/__token__(\d+)/g,et=/[&<"']/g -,tt=/['\n\r\t\u2028\u2029\\]/g,nt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),rt="__token__",it=[],st=I.concat,ot=R.hasOwnProperty,ut=I.push,at=R.propertyIsEnumerable,ft=I.slice,lt=R.toString,ct=Y.test(ct=ft.bind)&&ct,ht=Y.test(ht=Array.isArray)&&ht,pt=e.isFinite,dt=Y.test(dt=Object.keys)&&dt,vt="[object Arguments]",mt="[object Array]",gt="[object Boolean]",yt="[object Date]",bt="[object Number]",wt="[object Object]",Et="[object RegExp]" -,St="[object String]",xt=e.clearTimeout,Tt=e.setTimeout,Nt,Ct,kt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)kt=!n;Nt=4>(t+"").length,Ct="x"!=t[0]})(1);var Lt=!b(arguments),At="x"!=ft.call("x")[0],Ot="xx"!="x"[0]+Object("x")[0];try{var Mt=("[object Object]",lt.call(e.document||0)==wt)}catch(_t){}var Dt=ct&&/\n|Opera/.test(ct+lt.call(e.opera)),Pt=dt&&/^.+$|true/.test(dt+!!e.attachEvent),Ht={"[object Arguments]":n,"[object Array]" -:n,"[object Boolean]":i,"[object Date]":i,"[object Function]":i,"[object Number]":i,"[object Object]":i,"[object RegExp]":i,"[object String]":n},Bt={"[object Arguments]":i,"[object Array]":n,"[object Boolean]":n,"[object Date]":n,"[object Function]":i,"[object Number]":n,"[object Object]":n,"[object RegExp]":n,"[object String]":n},jt={"&":"&","<":"<",'"':""","'":"'"},Ft={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i,unknown:n},It={"\\":"\\","'":"'","\n":"n","\r" -:"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var qt={a:"b,a,w",j:"b",q:"if(!a)a=f;else if(w)a=i(a,w)",i:"if(a(y,g,b)===false)return s"},Rt={j:"{}",q:"var o;if(typeof a!='function'){var ii=a;a=function(y){return y[ii]}}else if(w)a=i(a,w)",i:"o=a(y,g,b);(e.call(s,o)?s[o]++:s[o]=1)"},Ut={j:"true",i:"if(!a(y,g,b))return!s"},zt={r:i,s:i,a:"l",j:"l",q:"for(var B=1,C=arguments.length;B-1&&j===j>>>0&&T(y.splice)))return!j",i:{l:"return false"}}),rn=dt?function(e){return"function"==typeof e&&at.call(e,"prototype")?Kt(e):dt(e)}:Kt,sn=a({a:"l",j:"[]",i:"s.push(y)"}),on=a({a:"b,hh",j:"false",o:i,d:{b:"if(x.call(h)==v)return b.indexOf(hh)>-1" -},i:"if(y===hh)return true"}),un=a(qt,Rt),an=a(qt,Ut),fn=a(qt,Wt),ln=a(qt,Xt,{j:"",i:"if(a(y,g,b))return y"}),cn=a(qt,Xt),hn=a(qt,Rt,{i:"o=a(y,g,b);(e.call(s,o)?s[o]:s[o]=[]).push(y)"}),pn=a($t,{a:"b,V",q:"var A=u.call(arguments,2),S=typeof V=='function'",i:{b:"s[g]=(S?V:y[V]).apply(y,A)",l:"s"+(Pt?"[m]=":".push")+"((S?V:y[V]).apply(y,A))"}}),dn=a(qt,$t),vn=a(zt,{a:"l,ee,O,ff",q:"var J,L,Q,gg,dd=O==U;if(!dd)ff=[];for(var B=1,C=dd?2:arguments.length;B1){for(var g=1;ge?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=M,s.bindAll=Sn,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=E,s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++nC(t,n)&&an(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke=pn,s.isArguments=b,s.isArray=Jt,s.isBoolean=function(e){return e===n||e===i||lt.call(e)==gt},s.isElement=function(e){return!!e&&1==e.nodeType},s.isEmpty=nn,s.isEqual=S,s.isFinite=function(e){return pt(e)&<.call(e)==bt},s.isFunction=w,s.isNaN=function(e){return lt.call -(e)==bt&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e&&Ft[typeof e]},s.isUndefined=function(e){return e===t},s.keys=rn,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:ft.call(e,-t||i)}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=dn,s.max=k,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments -[0];return ot.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=vn,s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0&&w(e.splice)?n:rn(e).length},s.some=bn,s.sortBy=wn,s.sortedIndex=A,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,n=n.variable;o==r&&(o=h.escape),a==r&& -(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,m)),f&&(e=e.replace(f,y)),a!=P&&(P=a,j=RegExp("|"+(a?"|"+a.source:""),"g")),o=it.length,e=e.replace(j,g),o=o!=it.length,e="__p += '"+e.replace(tt,c).replace(Z,l)+"';",it.length=0,n||(n=h.variable||H||"obj",o?e="with("+n+"){"+e+"}":(n!=H&&(H=n,B=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(G,"$&"+n+".").replace(B,"$1__d"))),e=(o?e.replace($,""):e).replace(J,"$1").replace(K,"$1;"),e="function("+n+"){"+ -n+"||("+n+"={});var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":",__d="+n+"."+n+"||"+n+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(p){u=function(){throw p}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Tt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++ -r>>0?(At?lt.call(e)==St:"string"==typeof e)?e.split(""):ft.call(e):sn(e)},s.union=function(){for(var e=-1,t=[],n=st.apply(t,arguments),r=n.length;++eC(t,n[e])&&t.push(n[e]);return t},s.uniq=O,s.uniqueId=function(e){var t=W++;return e?e+t:t},s.values=sn,s.where=En,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments -,1,20);++nn;n++)t+="g='"+u.p[n]+"';if(","constructor"==u.p[n]&&(t+="!(d&&d.prototype===h)&&"),t+="e.call(h,g)){y=h[g];"+u.m.i+"}"}if(u.c||u.n)t+="}"}return t+=u.e+";return s",Function("D,E,F,I,c,K,e,f,N,P,R,T,U,i,X,Y,k,p,u,v,x","var G=function("+e+"){"+t+"};return G")(Ht,I,M,f,st,Zt,ot,_,C,b,Jt,w,p,d,wt,Ft,dt,at,ft,St,lt)}function f(e,n){var r=e.b,i=n.b,e=e.a,n=n.a;return e===t?1:n===t?-1:en?1:r";var n=it.length;return it[n]="'+__e("+t+")+'" +,rt+n}function g(e,t,n,r){return e=it.length,t?it[e]="'+__e("+t+")+'":r?it[e]="';"+r+";__p+='":n&&(it[e]="'+((__t=("+n+"))==null?'':__t)+'"),rt+e}function y(e,t){if(V.test(t))return"";var n=it.length;return it[n]="'+((__t=("+t+"))==null?'':__t)+'",rt+n}function b(e){return lt.call(e)==vt}function w(e){return"function"==typeof e}function E(e,t,s,o,u){if(e==r)return e;s&&(t=i),u||(u={d:r}),u.d==r&&(u.d=!(!q.clone&&!U.clone&&!z.clone));if(((s=Ft[typeof e])||u.d)&&e.clone&&w(e.clone))return u +.d=r,e.clone(t);if(s){var a=lt.call(e);if(!Bt[a]||Lt&&b(e))return e;var f=a==mt,s=f||(a==wt?p(e,n):s)}if(!s||!t)return s?f?ft.call(e):Yt({},e):e;s=e.constructor;switch(a){case gt:return new s(e==n);case yt:return new s(+e);case bt:case St:return new s(e);case Et:return s(e.source,Q.exec(e))}o||(o=[]);for(a=o.length;a--;)if(o[a].c==e)return o[a].d;var a=e.length,l=f?s(a):{};o.push({d:l,c:e});if(f)for(f=-1;++f++u;)if(c=nt[u],ot.call(e,c)&&(!ot.call(t,c)||!S(e[c],t[c],s,o)))return i;return n}function x(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=d(t,r));if(-1>>0){var o=Ot&<.call(e)==St?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=rn(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function T(e,t,n){if(e)return t==r||n?e[0]:ft.call(e,0,t)}function N(e, +t){var n=[];if(!e)return n;for(var r,i=-1,s=e.length;++in?Math.max(0,i+n):n)-1}for(;++ri&&(i=e[s]);return i}for(n&&(t=d(t,n));++sr&&(r=n,i=e[s]);return i}function L(e,t,n){return e? +ft.call(e,t==r||n?1:t):[]}function A(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=M(n,r));for(t=n(t);i>>1,n(e[r])>>1,e[r]C(a,r))a.push(r),s.push(e[o]);return s}function M(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length? +s.concat(ft.call(o)):s),this instanceof n?(v.prototype=e.prototype,u=new v,(o=e.apply(u,o))&&Ft[typeof o]?o:u):e.apply(u,o)}var r,i=w(e);if(i){if(Dt||ct&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,$=/\b__p\+='';/g,J=/\b(__p\+=)''\+/g,K=/(__e\(.*?\)|\b__t\))\+'';/g,Q=/\w*$/,G=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,Y=RegExp("^"+(R.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g +,".+?")+"$"),Z=/__token__(\d+)/g,et=/[&<"']/g,tt=/['\n\r\t\u2028\u2029\\]/g,nt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),rt="__token__",it=[],st=I.concat,ot=R.hasOwnProperty,ut=I.push,at=R.propertyIsEnumerable,ft=I.slice,lt=R.toString,ct=Y.test(ct=ft.bind)&&ct,ht=Y.test(ht=Array.isArray)&&ht,pt=e.isFinite,dt=Y.test(dt=Object.keys)&&dt,vt="[object Arguments]",mt="[object Array]",gt="[object Boolean]",yt="[object Date]",bt="[object Number]" +,wt="[object Object]",Et="[object RegExp]",St="[object String]",xt=e.clearTimeout,Tt=e.setTimeout,Nt,Ct,kt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)kt=!n;Nt=4>(t+"").length,Ct="x"!=t[0]})(1);var Lt=!b(arguments),At="x"!=ft.call("x")[0],Ot="xx"!="x"[0]+Object("x")[0];try{var Mt=("[object Object]",lt.call(e.document||0)==wt)}catch(_t){}var Dt=ct&&/\n|Opera/.test(ct+lt.call(e.opera)),Pt=dt&&/^.+$|true/.test(dt+!!e.attachEvent +),Ht={"[object Arguments]":n,"[object Array]":n,"[object Boolean]":i,"[object Date]":i,"[object Function]":i,"[object Number]":i,"[object Object]":i,"[object RegExp]":i,"[object String]":n},Bt={"[object Arguments]":i,"[object Array]":n,"[object Boolean]":n,"[object Date]":n,"[object Function]":i,"[object Number]":n,"[object Object]":n,"[object RegExp]":n,"[object String]":n},jt={"&":"&","<":"<",'"':""","'":"'"},Ft={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i +,unknown:n},It={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var qt={a:"b,a,w",j:"b",q:"if(!a)a=f;else if(w)a=i(a,w)",i:"if(a(y,g,b)===false)return s"},Rt={j:"{}",q:"var o;if(typeof a!='function'){var ii=a;a=function(y){return y[ii]}}else if(w)a=i(a,w)",i:"o=a(y,g,b);(e.call(s,o)?s[o]++:s[o]=1)"},Ut={j:"true",i:"if(!a(y,g,b))return!s"},zt={r:i,s +:i,a:"l",j:"l",q:"for(var B=1,C=arguments.length;B-1&&j===j>>>0&&T(y.splice)))return!j",i:{l:"return false"}}),rn=dt?function(e){var t=typeof e;return"function"==t&&at.call(e,"prototype")?Kt(e):e&&Ft[t]?dt(e):[]}:Kt,sn=a(zt,{a:"l,ee,O,ff",q +:"var J,L,Q,gg,dd=O==U;if(!dd)ff=[];for(var B=1,C=dd?2:arguments.length;B-1"},i:"if(y===hh)return true"}),an=a(qt,Rt),fn=a(qt,Ut),ln=a(qt,Wt),cn=a(qt,Xt,{j:"" +,i:"if(a(y,g,b))return y"}),hn=a(qt,Xt),pn=a(qt,Rt,{i:"o=a(y,g,b);(e.call(s,o)?s[o]:s[o]=[]).push(y)"}),dn=a($t,{a:"b,V",q:"var A=u.call(arguments,2),S=typeof V=='function'",i:{b:"s[g]=(S?V:y[V]).apply(y,A)",l:"s"+(Pt?"[m]=":".push")+"((S?V:y[V]).apply(y,A))"}}),vn=a(qt,$t),mn=a($t,{a:"b,bb",i:{b:"s[g]=y[bb]",l:"s"+(Pt?"[m]=":".push")+"(y[bb])"}}),gn=a({a:"b,a,z,w",j:"z",q:"var W=arguments.length<3;if(w)a=i(a,w)",d:{b:"if(W)s=b[++g]"},i:{b:"s=a(s,y,g,b)",l:"s=W?(W=false,y):a(s,y,g,b)"}}),yn=a(qt, +Wt,{i:"!"+Wt.i}),bn=a(qt,Ut,{j:"false",i:Ut.i.replace("!","")}),wn=a(qt,Rt,$t,{i:{b:"s[g]={a:a(y,g,b),b:g,d:y}",l:"s"+(Pt?"[m]=":".push")+"({a:a(y,g,b),b:g,d:y})"},e:"s.sort(I);j=s.length;while(j--)s[j]=s[j].d"}),En=a(Wt,{a:"b,aa",q:"var Z,o,q,r=[];K(aa,function(y,o){r.push(o)});var cc=r.length",i:"for(Z=true,q=0;q1){for(var g=1;ge?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=M,s.bindAll=Sn,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=E,s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++nC(t,n)&&fn(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke= +dn,s.isArguments=b,s.isArray=Jt,s.isBoolean=function(e){return e===n||e===i||lt.call(e)==gt},s.isElement=function(e){return e?1===e.nodeType:i},s.isEmpty=nn,s.isEqual=S,s.isFinite=function(e){return pt(e)&<.call(e)==bt},s.isFunction=w,s.isNaN=function(e){return lt.call(e)==bt&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e?Ft[typeof e]:i},s.isUndefined=function(e){return e===t},s.keys=rn,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:ft.call(e,-t||i +)}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=vn,s.max=k,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return ot.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=sn,s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0&&w(e.splice)?n:rn(e).length},s.some=bn,s.sortBy=wn,s.sortedIndex=A,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,n=n.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,m)),f&&(e=e.replace(f,y)),a!=P&&(P=a,j=RegExp("|"+(a?"|"+a.source:""),"g")),o=it.length,e=e.replace(j,g),o= +o!=it.length,e="__p += '"+e.replace(tt,c).replace(Z,l)+"';",it.length=0,n||(n=h.variable||H||"obj",o?e="with("+n+"){"+e+"}":(n!=H&&(H=n,B=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(G,"$&"+n+".").replace(B,"$1__d"))),e=(o?e.replace($,""):e).replace(J,"$1").replace(K,"$1;"),e="function("+n+"){"+n+"||("+n+"={});var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":",__d="+n+"."+n+"||"+n+";")+e+"return __p}";try{u=Function("_","return "+e) +(s)}catch(p){u=function(){throw p}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Tt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?(At?lt.call(e)==St:"string"==typeof +e)?e.split(""):ft.call(e):on(e)},s.union=function(){for(var e=-1,t=[],n=st.apply(t,arguments),r=n.length;++eC(t,n[e])&&t.push(n[e]);return t},s.uniq=O,s.uniqueId=function(e){var t=W++;return e?e+t:t},s.values=on,s.where=En,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n Date: Sun, 19 Aug 2012 02:13:43 -0700 Subject: [PATCH 07/19] Cleanup `_.template` docs and generate less unused code in compiled templates. Former-commit-id: e6703414b83e9286d9ce5e14214375bbbaf9285f --- build/pre-compile.js | 5 +--- doc/README.md | 54 ++++++++++++++++++++++++-------------------- lodash.js | 53 ++++++++++++++++++++++++------------------- lodash.min.js | 10 ++++---- 4 files changed, 66 insertions(+), 56 deletions(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 069f770d22..887973d481 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -264,11 +264,8 @@ // http://code.google.com/closure/compiler/docs/api-tutorial3.html#export source = source.replace(RegExp('\\.(' + propWhitelist.join('|') + ')\\b', 'g'), "['$1']"); - // remove brackets from `_.escape()` in `tokenizeEscape` - source = source.replace(/_\['escape']\("/, '_.escape("'); - // remove brackets from `_.escape()` in `_.template` - source = source.replace(/__e *= *_\['escape']/, '__e=_.escape'); + source = source.replace(/__e *= *_\['escape']/g, '__e=_.escape'); // remove brackets from `collection.indexOf` in `_.contains` source = source.replace("collection['indexOf'](target)", 'collection.indexOf(target)'); diff --git a/doc/README.md b/doc/README.md index 48e4c1a6a3..fc04923309 100644 --- a/doc/README.md +++ b/doc/README.md @@ -152,7 +152,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4053 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4060 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -274,7 +274,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3978 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3985 "View in source") [Ⓣ][1] Wraps the value in a `lodash` wrapper object. @@ -2256,7 +2256,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) { ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4005 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4012 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -2286,7 +2286,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3781 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3787 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: For Chrome extensions use the `lodash csp` build and see http://code.google.com/chrome/extensions/trunk/sandboxingEval.html @@ -2300,7 +2300,7 @@ A micro-templating method that handles arbitrary delimiters, preserves whitespac #### Example ```js -// using compiled template +// using a compiled template var compiled = _.template('hello: <%= name %>'); compiled({ 'name': 'moe' }); // => 'hello: moe' @@ -2309,32 +2309,38 @@ var list = '<% _.forEach(people, function(name) { %>
  • <%= name %>
  • <% }); _.template(list, { 'people': ['moe', 'larry', 'curly'] }); // => '
  • moe
  • larry
  • curly
  • ' -var template = _.template('<%- value %>'); -template({ 'value': ' +// using the `source` property to inline compiled templates for meaningful +// line numbers in error messages and a stack trace +fs.writeFileSync(path.join(cwd, 'jst.js'), '\ + var JST = {\ + "main": ' + _.template(mainText).source + '\ + };\ +'); ``` * * * @@ -2370,7 +2376,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3921 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3928 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*. @@ -2480,7 +2486,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3948 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3955 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2669,7 +2675,7 @@ _.zipObject(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4023 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4030 "View in source") [Ⓣ][1] Enables method chaining on the wrapper object. @@ -2690,7 +2696,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4040 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4047 "View in source") [Ⓣ][1] Extracts the wrapped value. diff --git a/lodash.js b/lodash.js index a06b6af0f3..098eee1bb5 100644 --- a/lodash.js +++ b/lodash.js @@ -311,7 +311,7 @@ * @memberOf _.templateSettings * @type String */ - 'variable': 'obj' + 'variable': '' }; /*--------------------------------------------------------------------------*/ @@ -3742,7 +3742,7 @@ * is given, else it returns the interpolated text. * @example * - * // using compiled template + * // using a compiled template * var compiled = _.template('hello: <%= name %>'); * compiled({ 'name': 'moe' }); * // => 'hello: moe' @@ -3751,32 +3751,38 @@ * _.template(list, { 'people': ['moe', 'larry', 'curly'] }); * // => '
  • moe
  • larry
  • curly
  • ' * - * var template = _.template('<%- value %>'); - * template({ 'value': ' + * // using the `source` property to inline compiled templates for meaningful + * // line numbers in error messages and a stack trace + * fs.writeFileSync(path.join(cwd, 'jst.js'), '\ + * var JST = {\ + * "main": ' + _.template(mainText).source + '\ + * };\ + * '); */ function template(text, data, options) { // based on John Resig's `tmpl` implementation @@ -3791,7 +3797,8 @@ evaluateDelimiter = options.evaluate, interpolateDelimiter = options.interpolate, settings = lodash.templateSettings, - variable = options.variable; + variable = options.variable || settings.variable, + hasVariable = variable; // use default settings if no options object is provided if (escapeDelimiter == null) { @@ -3835,11 +3842,11 @@ // clear stored code snippets tokenized.length = 0; - // if `options.variable` is not specified and the template contains "evaluate" + // if `variable` is not specified and the template contains "evaluate" // delimiters, wrap a with-statement around the generated code to add the // data object to the top of the scope chain - if (!variable) { - variable = settings.variable || lastVariable || 'obj'; + if (!hasVariable) { + variable = lastVariable || 'obj'; if (isEvaluating) { text = 'with (' + variable + ') {\n' + text + '\n}\n'; @@ -3865,12 +3872,12 @@ // frame code as the function body text = 'function(' + variable + ') {\n' + - variable + ' || (' + variable + ' = {});\n' + + (hasVariable ? '' : variable + ' || (' + variable + ' = {});\n') + 'var __t, __p = \'\', __e = _.escape' + (isEvaluating ? ', __j = Array.prototype.join;\n' + 'function print() { __p += __j.call(arguments, \'\') }\n' - : ', __d = ' + variable + '.' + variable + ' || ' + variable + ';\n' + : (hasVariable ? '' : ', __d = ' + variable + '.' + variable + ' || ' + variable) + ';\n' ) + text + 'return __p\n}'; diff --git a/lodash.min.js b/lodash.min.js index b10a0bb374..a423d1999a 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -19,8 +19,8 @@ s.concat(ft.call(o)):s),this instanceof n?(v.prototype=e.prototype,u=new v,(o=e. ,".+?")+"$"),Z=/__token__(\d+)/g,et=/[&<"']/g,tt=/['\n\r\t\u2028\u2029\\]/g,nt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),rt="__token__",it=[],st=I.concat,ot=R.hasOwnProperty,ut=I.push,at=R.propertyIsEnumerable,ft=I.slice,lt=R.toString,ct=Y.test(ct=ft.bind)&&ct,ht=Y.test(ht=Array.isArray)&&ht,pt=e.isFinite,dt=Y.test(dt=Object.keys)&&dt,vt="[object Arguments]",mt="[object Array]",gt="[object Boolean]",yt="[object Date]",bt="[object Number]" ,wt="[object Object]",Et="[object RegExp]",St="[object String]",xt=e.clearTimeout,Tt=e.setTimeout,Nt,Ct,kt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)kt=!n;Nt=4>(t+"").length,Ct="x"!=t[0]})(1);var Lt=!b(arguments),At="x"!=ft.call("x")[0],Ot="xx"!="x"[0]+Object("x")[0];try{var Mt=("[object Object]",lt.call(e.document||0)==wt)}catch(_t){}var Dt=ct&&/\n|Opera/.test(ct+lt.call(e.opera)),Pt=dt&&/^.+$|true/.test(dt+!!e.attachEvent ),Ht={"[object Arguments]":n,"[object Array]":n,"[object Boolean]":i,"[object Date]":i,"[object Function]":i,"[object Number]":i,"[object Object]":i,"[object RegExp]":i,"[object String]":n},Bt={"[object Arguments]":i,"[object Array]":n,"[object Boolean]":n,"[object Date]":n,"[object Function]":i,"[object Number]":n,"[object Object]":n,"[object RegExp]":n,"[object String]":n},jt={"&":"&","<":"<",'"':""","'":"'"},Ft={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i -,unknown:n},It={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var qt={a:"b,a,w",j:"b",q:"if(!a)a=f;else if(w)a=i(a,w)",i:"if(a(y,g,b)===false)return s"},Rt={j:"{}",q:"var o;if(typeof a!='function'){var ii=a;a=function(y){return y[ii]}}else if(w)a=i(a,w)",i:"o=a(y,g,b);(e.call(s,o)?s[o]++:s[o]=1)"},Ut={j:"true",i:"if(!a(y,g,b))return!s"},zt={r:i,s -:i,a:"l",j:"l",q:"for(var B=1,C=arguments.length;B/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var qt={a:"b,a,w",j:"b",q:"if(!a)a=f;else if(w)a=i(a,w)",i:"if(a(y,g,b)===false)return s"},Rt={j:"{}",q:"var o;if(typeof a!='function'){var ii=a;a=function(y){return y[ii]}}else if(w)a=i(a,w)",i:"o=a(y,g,b);(e.call(s,o)?s[o]++:s[o]=1)"},Ut={j:"true",i:"if(!a(y,g,b))return!s"},zt={r:i,s:i, +a:"l",j:"l",q:"for(var B=1,C=arguments.length;B-1&&j===j>>>0&&T(y.splice)))return!j",i:{l:"return false"}}),rn=dt?function(e){var t=typeof e;return"function"==t&&at.call(e,"prototype")?Kt(e):e&&Ft[t]?dt(e):[]}:Kt,sn=a(zt,{a:"l,ee,O,ff",q :"var J,L,Q,gg,dd=O==U;if(!dd)ff=[];for(var B=1,C=dd?2:arguments.length;B-1"},i:"if(y===hh)return true"}),an=a(qt,Rt),fn=a(qt,Ut),ln=a(qt,Wt),cn=a(qt,Xt,{j:"" ,i:"if(a(y,g,b))return y"}),hn=a(qt,Xt),pn=a(qt,Rt,{i:"o=a(y,g,b);(e.call(s,o)?s[o]:s[o]=[]).push(y)"}),dn=a($t,{a:"b,V",q:"var A=u.call(arguments,2),S=typeof V=='function'",i:{b:"s[g]=(S?V:y[V]).apply(y,A)",l:"s"+(Pt?"[m]=":".push")+"((S?V:y[V]).apply(y,A))"}}),vn=a(qt,$t),mn=a($t,{a:"b,bb",i:{b:"s[g]=y[bb]",l:"s"+(Pt?"[m]=":".push")+"(y[bb])"}}),gn=a({a:"b,a,z,w",j:"z",q:"var W=arguments.length<3;if(w)a=i(a,w)",d:{b:"if(W)s=b[++g]"},i:{b:"s=a(s,y,g,b)",l:"s=W?(W=false,y):a(s,y,g,b)"}}),yn=a(qt, @@ -32,9 +32,9 @@ dn,s.isArguments=b,s.isArray=Jt,s.isBoolean=function(e){return e===n||e===i||lt. )}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=vn,s.max=k,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return ot.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=sn,s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0&&w(e.splice)?n:rn(e).length},s.some=bn,s.sortBy=wn,s.sortedIndex=A,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,n=n.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,m)),f&&(e=e.replace(f,y)),a!=P&&(P=a,j=RegExp("|"+(a?"|"+a.source:""),"g")),o=it.length,e=e.replace(j,g),o= -o!=it.length,e="__p += '"+e.replace(tt,c).replace(Z,l)+"';",it.length=0,n||(n=h.variable||H||"obj",o?e="with("+n+"){"+e+"}":(n!=H&&(H=n,B=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(G,"$&"+n+".").replace(B,"$1__d"))),e=(o?e.replace($,""):e).replace(J,"$1").replace(K,"$1;"),e="function("+n+"){"+n+"||("+n+"={});var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":",__d="+n+"."+n+"||"+n+";")+e+"return __p}";try{u=Function("_","return "+e) -(s)}catch(p){u=function(){throw p}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Tt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?(At?lt.call(e)==St:"string"==typeof +;return Ht[t]||Lt&&b(e)||t==wt&&-1>>0&&w(e.splice)?n:rn(e).length},s.some=bn,s.sortBy=wn,s.sortedIndex=A,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,p=n=n.variable||h.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,m)),f&&(e=e.replace(f,y)),a!=P&&(P=a,j=RegExp("|"+(a?"|"+a.source:""),"g")),o=it.length,e=e.replace +(j,g),o=o!=it.length,e="__p += '"+e.replace(tt,c).replace(Z,l)+"';",it.length=0,p||(n=H||"obj",o?e="with("+n+"){"+e+"}":(n!=H&&(H=n,B=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(G,"$&"+n+".").replace(B,"$1__d"))),e=(o?e.replace($,""):e).replace(J,"$1").replace(K,"$1;"),e="function("+n+"){"+(p?"":n+"||("+n+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(p?"":",__d="+n+"."+n+"||"+n)+";")+e+"return __p}";try{u=Function("_" +,"return "+e)(s)}catch(d){u=function(){throw d}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Tt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?(At?lt.call(e)==St:"string"==typeof e)?e.split(""):ft.call(e):on(e)},s.union=function(){for(var e=-1,t=[],n=st.apply(t,arguments),r=n.length;++eC(t,n[e])&&t.push(n[e]);return t},s.uniq=O,s.uniqueId=function(e){var t=W++;return e?e+t:t},s.values=on,s.where=En,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n Date: Sun, 19 Aug 2012 13:34:58 -0700 Subject: [PATCH 08/19] Ensure `_.template` won't error when passed falsey values, add `_.template` documentation, and DRY out `tokenizeEvaluate`. Former-commit-id: b575de8bf968c2fc2655eadff0a09bcbff1e1753 --- doc/README.md | 186 +++++++++++++++++++++++++------------------------- lodash.js | 28 ++++---- lodash.min.js | 66 +++++++++--------- test/test.js | 1 - 4 files changed, 142 insertions(+), 139 deletions(-) diff --git a/doc/README.md b/doc/README.md index fc04923309..8e89b6f2c7 100644 --- a/doc/README.md +++ b/doc/README.md @@ -152,7 +152,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4064 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -164,7 +164,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3151 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -192,7 +192,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3206 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3205 "View in source") [Ⓣ][1] Creates a new function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. Lazy defined methods may be bound by passing the object they are bound to as `func` and the method name as `thisArg`. @@ -243,7 +243,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3275 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -274,7 +274,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3985 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3989 "View in source") [Ⓣ][1] Wraps the value in a `lodash` wrapper object. @@ -308,7 +308,7 @@ var youngest = _.chain(stooges) ### `_.clone(value, deep [, guard, stack=[]], thorough)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L992 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned otherwise they will be assigned by reference. If a value has a `clone` method it will be used to perform the clone. Functions, DOM nodes, `arguments` objects, and objects created by constructors other than `Object` are **not** cloned unless they have a custom `clone` method. @@ -350,7 +350,7 @@ shallow[0] === stooges[0]; ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2391 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2390 "View in source") [Ⓣ][1] Creates a new array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -374,7 +374,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3313 "View in source") [Ⓣ][1] Creates a new function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. @@ -401,7 +401,7 @@ welcome('moe'); ### `_.contains(collection, target)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1875 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1874 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. @@ -432,7 +432,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1911 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1910 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -464,7 +464,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3346 "View in source") [Ⓣ][1] Creates a new function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -490,7 +490,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1094 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1093 "View in source") [Ⓣ][1] Assigns enumerable properties of the default object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -516,7 +516,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3412 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3411 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -541,7 +541,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3391 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -568,7 +568,7 @@ _.delay(log, 1000, 'logged later'); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2423 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2422 "View in source") [Ⓣ][1] Creates a new array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -593,7 +593,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.drop(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1114 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1113 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. @@ -618,7 +618,7 @@ _.drop({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'userid'); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3609 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3608 "View in source") [Ⓣ][1] Escapes a string for inclusion in HTML, replacing `&`, `<`, `"`, and `'` characters. @@ -642,7 +642,7 @@ _.escape('Moe, Larry & Curly'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1931 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1930 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -668,7 +668,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1138 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1137 "View in source") [Ⓣ][1] Assigns enumerable properties of the source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -693,7 +693,7 @@ _.extend({ 'name': 'moe' }, { 'age': 40 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1951 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1950 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -719,7 +719,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1972 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1971 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -745,7 +745,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.first(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2460 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2459 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -771,7 +771,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2484 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2483 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -799,7 +799,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.forEach(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1999 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1998 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -828,7 +828,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.forIn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1167 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -864,7 +864,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1192 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1191 "View in source") [Ⓣ][1] Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -892,7 +892,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1209 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1208 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -916,7 +916,7 @@ _.functions(_); ### `_.groupBy(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2027 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2026 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -948,7 +948,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1232 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1231 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -973,7 +973,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3629 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3628 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -998,7 +998,7 @@ moe === _.identity(moe); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2528 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2527 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster binary search. @@ -1030,7 +1030,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2568 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2567 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -1056,7 +1056,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2590 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2589 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -1080,7 +1080,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2055 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2054 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1109,7 +1109,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L886 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L885 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -1136,7 +1136,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L912 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L911 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -1163,7 +1163,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1249 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1248 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -1187,7 +1187,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1265 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -1211,7 +1211,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1282 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -1235,7 +1235,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1307 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -1265,7 +1265,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, stack=[]], thorough)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1350 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1349 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If a value has an `isEqual` method it will be used to perform the comparison. @@ -1298,7 +1298,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1523 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1522 "View in source") [Ⓣ][1] Checks if `value` is a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and other values. See http://es5.github.com/#x15.1.2.5. @@ -1328,7 +1328,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L929 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L928 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -1352,7 +1352,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1578 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1577 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return true for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. @@ -1385,7 +1385,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1601 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1600 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -1412,7 +1412,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1618 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1617 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -1436,7 +1436,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1543 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -1463,7 +1463,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1635 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1634 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -1487,7 +1487,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1652 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1651 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -1511,7 +1511,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1670 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1669 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -1535,7 +1535,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1687 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1686 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -1559,7 +1559,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.last(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2631 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2630 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the lasy `n` elementsvof the `array`. @@ -1585,7 +1585,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2656 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. @@ -1614,7 +1614,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2089 "View in source") [Ⓣ][1] Creates a new array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -1643,7 +1643,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2696 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1675,7 +1675,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3435 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3434 "View in source") [Ⓣ][1] Creates a new function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. @@ -1701,7 +1701,7 @@ var fibonacci = _.memoize(function(n) { ### `_.merge(object [, source1, source2, ..., indicator, stack=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1729 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1728 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1738,7 +1738,7 @@ _.merge(stooges, ages); ### `_.min(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2747 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2746 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1764,7 +1764,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3655 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3654 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1794,7 +1794,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3686 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3685 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1814,7 +1814,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3461 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3460 "View in source") [Ⓣ][1] Creates a new function that is restricted to one execution. Repeat calls to the function will return the value of the first call. @@ -1840,7 +1840,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3495 "View in source") [Ⓣ][1] Creates a new function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar `bind`, except it does **not** alter the `this` binding. @@ -1867,7 +1867,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1771 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. @@ -1892,7 +1892,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2113 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2112 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1923,7 +1923,7 @@ _.pluck(stooges, 'name'); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2808 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2807 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -1961,7 +1961,7 @@ _.range(0); ### `_.reduce(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2140 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1988,7 +1988,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2178 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2177 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -2016,7 +2016,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2234 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2233 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -2042,7 +2042,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.rest(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2847 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2846 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -2068,7 +2068,7 @@ _.rest([3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3718 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3717 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2103,7 +2103,7 @@ _.result(object, 'stuff'); ### `_.shuffle(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2868 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2867 "View in source") [Ⓣ][1] Creates a new array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -2127,7 +2127,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1813 "View in source") [Ⓣ][1] Gets the size of `value` by returning `value.length` if `value` is an array, string, or `arguments` object. If `value` is an object, size is determined by returning the number of own enumerable properties it has. @@ -2157,7 +2157,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2257 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2256 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. @@ -2183,7 +2183,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2287 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2286 "View in source") [Ⓣ][1] Creates a new array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -2215,7 +2215,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2920 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2919 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with `1` argument; *(value)*. @@ -2256,7 +2256,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) { ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4012 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4016 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -2286,9 +2286,9 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3790 "View in source") [Ⓣ][1] -A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: For Chrome extensions use the `lodash csp` build and see http://code.google.com/chrome/extensions/trunk/sandboxingEval.html +A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html #### Arguments 1. `text` *(String)*: The template text. @@ -2325,7 +2325,7 @@ _.templateSettings = { _.template('Hello {{ name }}!', { 'name': 'Mustache' }); // => 'Hello Mustache!' -// using the `variable` option to ensure a with-statement isn't used in a compiled template +// using the `variable` option to ensure a with-statement isn't used in the compiled template var compiled = _.template('hello: <%= data.name %>', null, { 'variable': 'data' }); compiled.source; // => function(data) { @@ -2351,7 +2351,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3532 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3531 "View in source") [Ⓣ][1] Creates a new function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2376,7 +2376,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3932 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*. @@ -2402,7 +2402,7 @@ _.times(3, function() { this.grantWish(); }, genie); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2324 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2323 "View in source") [Ⓣ][1] Converts the `collection`, into an array. Useful for converting the `arguments` object. @@ -2426,7 +2426,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2961 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -2450,7 +2450,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3005 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3004 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -2486,7 +2486,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3959 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2510,7 +2510,7 @@ _.uniqueId('contact_'); ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1845 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1844 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2534,7 +2534,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2361 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2360 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -2565,7 +2565,7 @@ _.where(stooges, { 'age': 40 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3054 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3053 "View in source") [Ⓣ][1] Creates a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2590,7 +2590,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3583 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3582 "View in source") [Ⓣ][1] Creates a new function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the new function are appended to those passed to the `wrapper` function. @@ -2619,7 +2619,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3087 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3086 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -2643,7 +2643,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3116 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [Ⓣ][1] Creates an object composed from an array of `keys` and an array of `values`. @@ -2675,7 +2675,7 @@ _.zipObject(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4030 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4034 "View in source") [Ⓣ][1] Enables method chaining on the wrapper object. @@ -2696,7 +2696,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4051 "View in source") [Ⓣ][1] Extracts the wrapped value. diff --git a/lodash.js b/lodash.js index 098eee1bb5..6bdb56b783 100644 --- a/lodash.js +++ b/lodash.js @@ -817,7 +817,7 @@ * @returns {String} Returns a token. */ function tokenizeEscape(match, value) { - if (reComplexDelimiter.test(value)) { + if (match && reComplexDelimiter.test(value)) { return ''; } var index = tokenized.length; @@ -837,15 +837,14 @@ * @returns {String} Returns a token. */ function tokenizeEvaluate(match, escapeValue, interpolateValue, evaluateValue) { - var index = tokenized.length; - if (escapeValue) { - tokenized[index] = "' +\n__e(" + escapeValue + ") +\n'"; - } else if (evaluateValue) { + if (evaluateValue) { + var index = tokenized.length; tokenized[index] = "';\n" + evaluateValue + ";\n__p += '"; - } else if (interpolateValue) { - tokenized[index] = "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; + return token + index; } - return token + index; + return escapeValue + ? tokenizeEscape(null, escapeValue) + : tokenizeInterpolate(null, interpolateValue); } /** @@ -857,7 +856,7 @@ * @returns {String} Returns a token. */ function tokenizeInterpolate(match, value) { - if (reComplexDelimiter.test(value)) { + if (match && reComplexDelimiter.test(value)) { return ''; } var index = tokenized.length; @@ -3729,8 +3728,12 @@ * A micro-templating method that handles arbitrary delimiters, preserves * whitespace, and correctly escapes quotes within interpolated code. * - * Note: For Chrome extensions use the `lodash csp` build and see - * http://code.google.com/chrome/extensions/trunk/sandboxingEval.html + * Note: In the development build `_.template` utilizes sourceURLs for easier + * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl + * + * Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` + * build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. + * See http://developer.chrome.com/trunk/extensions/sandboxingEval.html * * @static * @memberOf _ @@ -3767,7 +3770,7 @@ * _.template('Hello {{ name }}!', { 'name': 'Mustache' }); * // => 'Hello Mustache!' * - * // using the `variable` option to ensure a with-statement isn't used in a compiled template + * // using the `variable` option to ensure a with-statement isn't used in the compiled template * var compiled = _.template('hello: <%= data.name %>', null, { 'variable': 'data' }); * compiled.source; * // => function(data) { @@ -3790,6 +3793,7 @@ // and Laura Doktorova's doT.js // https://github.com/olado/doT options || (options = {}); + text += ''; var isEvaluating, result, diff --git a/lodash.min.js b/lodash.min.js index a423d1999a..e8a27f2b5e 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -6,36 +6,36 @@ )?("string"==typeof n&&(n={b:n,l:n}),u.c[t]=n.b,u.m[t]=n.l):u[t]=n;e=u.a,t=/^[^,]+/.exec(e)[0],u.g=t,u.h=Nt,u.k=Pt,u.n=kt,u.p=nt,u.r=u.r!==i,u.s=u.s!==i,"o"in u||(u.o=Ot),u.f||(u.f="if(!"+t+")return s");if("b"!=t||!u.c.i)u.c=r;t="",u.s&&(t+="'use strict';"),t+="var g,y,h="+u.g+",s",u.j&&(t+="="+u.j),t+=";"+u.f+";"+u.q+";",u.c&&(t+="var j=h.length;g=-1;",u.m&&(t+="if(j>-1&&j===j>>>0){"),u.o&&(t+="if(x.call(h)==v){h=h.split('')}"),t+=u.c.d+";while(++gn;n++)t+="g='"+u.p[n]+"';if(","constructor"==u.p[n]&&(t+="!(d&&d.prototype===h)&&"),t+="e.call(h,g)){y=h[g];"+u.m.i+"}"}if(u.c||u.n)t+="}"}return t+=u.e+";return s",Function("D,E,F,I,c,K,e,f,N,P,R,T,U,i,X,Y,k,p,u,v,x","var G=function("+e+"){"+t+"};return G")(Ht,I,M,f,st,Zt,ot,_,C,b,Jt,w,p,d,wt,Ft,dt,at,ft,St,lt)}function f(e,n){var r=e.b,i=n.b,e=e.a,n=n.a;return e===t?1:n===t?-1:en?1:r";var n=it.length;return it[n]="'+__e("+t+")+'" -,rt+n}function g(e,t,n,r){return e=it.length,t?it[e]="'+__e("+t+")+'":r?it[e]="';"+r+";__p+='":n&&(it[e]="'+((__t=("+n+"))==null?'':__t)+'"),rt+e}function y(e,t){if(V.test(t))return"";var n=it.length;return it[n]="'+((__t=("+t+"))==null?'':__t)+'",rt+n}function b(e){return lt.call(e)==vt}function w(e){return"function"==typeof e}function E(e,t,s,o,u){if(e==r)return e;s&&(t=i),u||(u={d:r}),u.d==r&&(u.d=!(!q.clone&&!U.clone&&!z.clone));if(((s=Ft[typeof e])||u.d)&&e.clone&&w(e.clone))return u -.d=r,e.clone(t);if(s){var a=lt.call(e);if(!Bt[a]||Lt&&b(e))return e;var f=a==mt,s=f||(a==wt?p(e,n):s)}if(!s||!t)return s?f?ft.call(e):Yt({},e):e;s=e.constructor;switch(a){case gt:return new s(e==n);case yt:return new s(+e);case bt:case St:return new s(e);case Et:return s(e.source,Q.exec(e))}o||(o=[]);for(a=o.length;a--;)if(o[a].c==e)return o[a].d;var a=e.length,l=f?s(a):{};o.push({d:l,c:e});if(f)for(f=-1;++f++u;)if(c=nt[u],ot.call(e,c)&&(!ot.call(t,c)||!S(e[c],t[c],s,o)))return i;return n}function x(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=d(t,r));if(-1>>0){var o=Ot&<.call(e)==St?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=rn(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function T(e,t,n){if(e)return t==r||n?e[0]:ft.call(e,0,t)}function N(e, -t){var n=[];if(!e)return n;for(var r,i=-1,s=e.length;++in?Math.max(0,i+n):n)-1}for(;++ri&&(i=e[s]);return i}for(n&&(t=d(t,n));++sr&&(r=n,i=e[s]);return i}function L(e,t,n){return e? -ft.call(e,t==r||n?1:t):[]}function A(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=M(n,r));for(t=n(t);i>>1,n(e[r])>>1,e[r]C(a,r))a.push(r),s.push(e[o]);return s}function M(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length? -s.concat(ft.call(o)):s),this instanceof n?(v.prototype=e.prototype,u=new v,(o=e.apply(u,o))&&Ft[typeof o]?o:u):e.apply(u,o)}var r,i=w(e);if(i){if(Dt||ct&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,$=/\b__p\+='';/g,J=/\b(__p\+=)''\+/g,K=/(__e\(.*?\)|\b__t\))\+'';/g,Q=/\w*$/,G=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,Y=RegExp("^"+(R.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g -,".+?")+"$"),Z=/__token__(\d+)/g,et=/[&<"']/g,tt=/['\n\r\t\u2028\u2029\\]/g,nt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),rt="__token__",it=[],st=I.concat,ot=R.hasOwnProperty,ut=I.push,at=R.propertyIsEnumerable,ft=I.slice,lt=R.toString,ct=Y.test(ct=ft.bind)&&ct,ht=Y.test(ht=Array.isArray)&&ht,pt=e.isFinite,dt=Y.test(dt=Object.keys)&&dt,vt="[object Arguments]",mt="[object Array]",gt="[object Boolean]",yt="[object Date]",bt="[object Number]" -,wt="[object Object]",Et="[object RegExp]",St="[object String]",xt=e.clearTimeout,Tt=e.setTimeout,Nt,Ct,kt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)kt=!n;Nt=4>(t+"").length,Ct="x"!=t[0]})(1);var Lt=!b(arguments),At="x"!=ft.call("x")[0],Ot="xx"!="x"[0]+Object("x")[0];try{var Mt=("[object Object]",lt.call(e.document||0)==wt)}catch(_t){}var Dt=ct&&/\n|Opera/.test(ct+lt.call(e.opera)),Pt=dt&&/^.+$|true/.test(dt+!!e.attachEvent -),Ht={"[object Arguments]":n,"[object Array]":n,"[object Boolean]":i,"[object Date]":i,"[object Function]":i,"[object Number]":i,"[object Object]":i,"[object RegExp]":i,"[object String]":n},Bt={"[object Arguments]":i,"[object Array]":n,"[object Boolean]":n,"[object Date]":n,"[object Function]":i,"[object Number]":n,"[object Object]":n,"[object RegExp]":n,"[object String]":n},jt={"&":"&","<":"<",'"':""","'":"'"},Ft={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i -,unknown:n},It={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var qt={a:"b,a,w",j:"b",q:"if(!a)a=f;else if(w)a=i(a,w)",i:"if(a(y,g,b)===false)return s"},Rt={j:"{}",q:"var o;if(typeof a!='function'){var ii=a;a=function(y){return y[ii]}}else if(w)a=i(a,w)",i:"o=a(y,g,b);(e.call(s,o)?s[o]++:s[o]=1)"},Ut={j:"true",i:"if(!a(y,g,b))return!s"},zt={r:i,s:i, -a:"l",j:"l",q:"for(var B=1,C=arguments.length;B-1&&j===j>>>0&&T(y.splice)))return!j",i:{l:"return false"}}),rn=dt?function(e){var t=typeof e;return"function"==t&&at.call(e,"prototype")?Kt(e):e&&Ft[t]?dt(e):[]}:Kt,sn=a(zt,{a:"l,ee,O,ff",q -:"var J,L,Q,gg,dd=O==U;if(!dd)ff=[];for(var B=1,C=dd?2:arguments.length;B-1"},i:"if(y===hh)return true"}),an=a(qt,Rt),fn=a(qt,Ut),ln=a(qt,Wt),cn=a(qt,Xt,{j:"" -,i:"if(a(y,g,b))return y"}),hn=a(qt,Xt),pn=a(qt,Rt,{i:"o=a(y,g,b);(e.call(s,o)?s[o]:s[o]=[]).push(y)"}),dn=a($t,{a:"b,V",q:"var A=u.call(arguments,2),S=typeof V=='function'",i:{b:"s[g]=(S?V:y[V]).apply(y,A)",l:"s"+(Pt?"[m]=":".push")+"((S?V:y[V]).apply(y,A))"}}),vn=a(qt,$t),mn=a($t,{a:"b,bb",i:{b:"s[g]=y[bb]",l:"s"+(Pt?"[m]=":".push")+"(y[bb])"}}),gn=a({a:"b,a,z,w",j:"z",q:"var W=arguments.length<3;if(w)a=i(a,w)",d:{b:"if(W)s=b[++g]"},i:{b:"s=a(s,y,g,b)",l:"s=W?(W=false,y):a(s,y,g,b)"}}),yn=a(qt, -Wt,{i:"!"+Wt.i}),bn=a(qt,Ut,{j:"false",i:Ut.i.replace("!","")}),wn=a(qt,Rt,$t,{i:{b:"s[g]={a:a(y,g,b),b:g,d:y}",l:"s"+(Pt?"[m]=":".push")+"({a:a(y,g,b),b:g,d:y})"},e:"s.sort(I);j=s.length;while(j--)s[j]=s[j].d"}),En=a(Wt,{a:"b,aa",q:"var Z,o,q,r=[];K(aa,function(y,o){r.push(o)});var cc=r.length",i:"for(Z=true,q=0;q1){for(var g=1;ge?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=M,s.bindAll=Sn,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=E,s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++nC(t,n)&&fn(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke= -dn,s.isArguments=b,s.isArray=Jt,s.isBoolean=function(e){return e===n||e===i||lt.call(e)==gt},s.isElement=function(e){return e?1===e.nodeType:i},s.isEmpty=nn,s.isEqual=S,s.isFinite=function(e){return pt(e)&<.call(e)==bt},s.isFunction=w,s.isNaN=function(e){return lt.call(e)==bt&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e?Ft[typeof e]:i},s.isUndefined=function(e){return e===t},s.keys=rn,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:ft.call(e,-t||i -)}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=vn,s.max=k,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return ot.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=sn,s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0&&w(e.splice)?n:rn(e).length},s.some=bn,s.sortBy=wn,s.sortedIndex=A,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,p=n=n.variable||h.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,m)),f&&(e=e.replace(f,y)),a!=P&&(P=a,j=RegExp("|"+(a?"|"+a.source:""),"g")),o=it.length,e=e.replace -(j,g),o=o!=it.length,e="__p += '"+e.replace(tt,c).replace(Z,l)+"';",it.length=0,p||(n=H||"obj",o?e="with("+n+"){"+e+"}":(n!=H&&(H=n,B=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(G,"$&"+n+".").replace(B,"$1__d"))),e=(o?e.replace($,""):e).replace(J,"$1").replace(K,"$1;"),e="function("+n+"){"+(p?"":n+"||("+n+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(p?"":",__d="+n+"."+n+"||"+n)+";")+e+"return __p}";try{u=Function("_" -,"return "+e)(s)}catch(d){u=function(){throw d}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Tt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?(At?lt.call(e)==St:"string"==typeof -e)?e.split(""):ft.call(e):on(e)},s.union=function(){for(var e=-1,t=[],n=st.apply(t,arguments),r=n.length;++eC(t,n[e])&&t.push(n[e]);return t},s.uniq=O,s.uniqueId=function(e){var t=W++;return e?e+t:t},s.values=on,s.where=En,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n";var n=it.length;return it[n]="'+__e("+t+")+'" +,rt+n}function g(e,t,n,i){return i?(e=it.length,it[e]="';"+i+";__p+='",rt+e):t?m(r,t):y(r,n)}function y(e,t){if(e&&V.test(t))return"";var n=it.length;return it[n]="'+((__t=("+t+"))==null?'':__t)+'",rt+n}function b(e){return lt.call(e)==vt}function w(e){return"function"==typeof e}function E(e,t,s,o,u){if(e==r)return e;s&&(t=i),u||(u={d:r}),u.d==r&&(u.d=!(!q.clone&&!U.clone&&!z.clone));if(((s=Ft[typeof e])||u.d)&&e.clone&&w(e.clone))return u.d=r,e.clone(t);if(s){var a=lt.call(e);if(!Bt[a +]||Lt&&b(e))return e;var f=a==mt,s=f||(a==wt?p(e,n):s)}if(!s||!t)return s?f?ft.call(e):Yt({},e):e;s=e.constructor;switch(a){case gt:return new s(e==n);case yt:return new s(+e);case bt:case St:return new s(e);case Et:return s(e.source,Q.exec(e))}o||(o=[]);for(a=o.length;a--;)if(o[a].c==e)return o[a].d;var a=e.length,l=f?s(a):{};o.push({d:l,c:e});if(f)for(f=-1;++f++u;)if(c=nt[u],ot.call(e,c)&&(!ot.call(t,c)||!S(e[c],t[c],s,o)))return i;return n}function x(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=d(t,r));if(-1>>0){var o=Ot&<.call(e)==St?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=rn(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function T(e,t,n){if(e)return t==r||n?e[0]:ft.call(e,0,t)}function N(e,t){var n=[];if(!e)return n;for(var r,i=-1,s=e.length +;++in?Math.max(0,i+n):n)-1}for(;++ri&&(i=e[s]);return i}for(n&&(t=d(t,n));++sr&&(r=n,i=e[s]);return i}function L(e,t,n){return e?ft.call(e,t==r||n?1:t):[]}function A(e,t,n,r){if(! +e)return 0;var i=0,s=e.length;if(n){r&&(n=M(n,r));for(t=n(t);i>>1,n(e[r])>>1,e[r]C(a,r))a.push(r),s.push(e[o]);return s}function M(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length?s.concat(ft.call(o)):s),this instanceof n?(v.prototype= +e.prototype,u=new v,(o=e.apply(u,o))&&Ft[typeof o]?o:u):e.apply(u,o)}var r,i=w(e);if(i){if(Dt||ct&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,$=/\b__p\+='';/g,J=/\b(__p\+=)''\+/g,K=/(__e\(.*?\)|\b__t\))\+'';/g,Q=/\w*$/,G=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,Y=RegExp("^"+(R.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Z=/__token__(\d+)/g,et=/[&<"']/g +,tt=/['\n\r\t\u2028\u2029\\]/g,nt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),rt="__token__",it=[],st=I.concat,ot=R.hasOwnProperty,ut=I.push,at=R.propertyIsEnumerable,ft=I.slice,lt=R.toString,ct=Y.test(ct=ft.bind)&&ct,ht=Y.test(ht=Array.isArray)&&ht,pt=e.isFinite,dt=Y.test(dt=Object.keys)&&dt,vt="[object Arguments]",mt="[object Array]",gt="[object Boolean]",yt="[object Date]",bt="[object Number]",wt="[object Object]",Et="[object RegExp]" +,St="[object String]",xt=e.clearTimeout,Tt=e.setTimeout,Nt,Ct,kt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)kt=!n;Nt=4>(t+"").length,Ct="x"!=t[0]})(1);var Lt=!b(arguments),At="x"!=ft.call("x")[0],Ot="xx"!="x"[0]+Object("x")[0];try{var Mt=("[object Object]",lt.call(e.document||0)==wt)}catch(_t){}var Dt=ct&&/\n|Opera/.test(ct+lt.call(e.opera)),Pt=dt&&/^.+$|true/.test(dt+!!e.attachEvent),Ht={"[object Arguments]":n,"[object Array]" +:n,"[object Boolean]":i,"[object Date]":i,"[object Function]":i,"[object Number]":i,"[object Object]":i,"[object RegExp]":i,"[object String]":n},Bt={"[object Arguments]":i,"[object Array]":n,"[object Boolean]":n,"[object Date]":n,"[object Function]":i,"[object Number]":n,"[object Object]":n,"[object RegExp]":n,"[object String]":n},jt={"&":"&","<":"<",'"':""","'":"'"},Ft={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i,unknown:n},It={"\\":"\\","'":"'","\n":"n","\r" +:"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var qt={a:"b,a,w",j:"b",q:"if(!a)a=f;else if(w)a=i(a,w)",i:"if(a(y,g,b)===false)return s"},Rt={j:"{}",q:"var o;if(typeof a!='function'){var ii=a;a=function(y){return y[ii]}}else if(w)a=i(a,w)",i:"o=a(y,g,b);(e.call(s,o)?s[o]++:s[o]=1)"},Ut={j:"true",i:"if(!a(y,g,b))return!s"},zt={r:i,s:i,a:"l",j:"l",q:"for(var B=1,C=arguments.length;B-1&&j===j>>>0&&T(y.splice)))return!j",i:{l:"return false"}}),rn=dt?function(e){var t=typeof e;return"function"==t&&at.call(e,"prototype")?Kt(e):e&&Ft[t]?dt(e):[]}:Kt,sn=a(zt,{a:"l,ee,O,ff",q:"var J,L,Q,gg,dd=O==U;if(!dd)ff=[];for(var B=1,C=dd?2:arguments.length;B-1"},i:"if(y===hh)return true"}),an=a(qt,Rt),fn=a(qt,Ut),ln=a(qt,Wt),cn=a(qt,Xt,{j:"",i:"if(a(y,g,b))return y"}),hn=a(qt,Xt),pn=a(qt,Rt,{i:"o=a(y,g,b);(e.call(s,o)?s[o]:s[o]=[]).push(y)" +}),dn=a($t,{a:"b,V",q:"var A=u.call(arguments,2),S=typeof V=='function'",i:{b:"s[g]=(S?V:y[V]).apply(y,A)",l:"s"+(Pt?"[m]=":".push")+"((S?V:y[V]).apply(y,A))"}}),vn=a(qt,$t),mn=a($t,{a:"b,bb",i:{b:"s[g]=y[bb]",l:"s"+(Pt?"[m]=":".push")+"(y[bb])"}}),gn=a({a:"b,a,z,w",j:"z",q:"var W=arguments.length<3;if(w)a=i(a,w)",d:{b:"if(W)s=b[++g]"},i:{b:"s=a(s,y,g,b)",l:"s=W?(W=false,y):a(s,y,g,b)"}}),yn=a(qt,Wt,{i:"!"+Wt.i}),bn=a(qt,Ut,{j:"false",i:Ut.i.replace("!","")}),wn=a(qt,Rt,$t,{i:{b:"s[g]={a:a(y,g,b),b:g,d:y}" +,l:"s"+(Pt?"[m]=":".push")+"({a:a(y,g,b),b:g,d:y})"},e:"s.sort(I);j=s.length;while(j--)s[j]=s[j].d"}),En=a(Wt,{a:"b,aa",q:"var Z,o,q,r=[];K(aa,function(y,o){r.push(o)});var cc=r.length",i:"for(Z=true,q=0;q1){for(var g=1;ge?t():function(){if(1>--e)return t.apply +(this,arguments)}},s.bind=M,s.bindAll=Sn,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=E,s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++nC(t,n)&&fn(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke=dn,s.isArguments=b,s.isArray=Jt,s.isBoolean=function(e){return e===n||e===i||lt. +call(e)==gt},s.isElement=function(e){return e?1===e.nodeType:i},s.isEmpty=nn,s.isEqual=S,s.isFinite=function(e){return pt(e)&<.call(e)==bt},s.isFunction=w,s.isNaN=function(e){return lt.call(e)==bt&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e?Ft[typeof e]:i},s.isUndefined=function(e){return e===t},s.keys=rn,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:ft.call(e,-t||i)}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof +n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=vn,s.max=k,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return ot.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=sn,s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s>>0&&w(e.splice)?n:rn(e).length},s.some= +bn,s.sortBy=wn,s.sortedIndex=A,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var e=e+"",o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,p=n=n.variable||h.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,m)),f&&(e=e.replace(f,y)),a!=P&&(P=a,j=RegExp("|"+(a?"|"+a.source:""),"g")),o=it.length,e=e.replace(j,g),o=o!=it.length,e="__p += '"+e.replace(tt,c).replace(Z,l)+"';",it. +length=0,p||(n=H||"obj",o?e="with("+n+"){"+e+"}":(n!=H&&(H=n,B=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(G,"$&"+n+".").replace(B,"$1__d"))),e=(o?e.replace($,""):e).replace(J,"$1").replace(K,"$1;"),e="function("+n+"){"+(p?"":n+"||("+n+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(p?"":",__d="+n+"."+n+"||"+n)+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(d){u=function(){throw d}}return t?u(t):(u.source= +e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=Tt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?(At?lt.call(e)==St:"string"==typeof e)?e.split(""):ft.call(e):on(e)},s.union=function(){for(var e=-1 +,t=[],n=st.apply(t,arguments),r=n.length;++eC(t,n[e])&&t.push(n[e]);return t},s.uniq=O,s.uniqueId=function(e){var t=W++;return e?e+t:t},s.values=on,s.where=En,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n Date: Sun, 19 Aug 2012 15:35:38 -0700 Subject: [PATCH 09/19] Avoid using the nano applet in perf/index.html if it isn't needed. Former-commit-id: 342983337140dd5608848b7f09d24038ea61d1a1 --- perf/index.html | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/perf/index.html b/perf/index.html index 1427bb46ff..b53f458a81 100644 --- a/perf/index.html +++ b/perf/index.html @@ -27,8 +27,23 @@ + - From 387cc184e6a37d0b947e19468b0e76b15632c2d8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 21 Aug 2012 01:31:54 -0700 Subject: [PATCH 14/19] Keep test count consistent for Node.js. Former-commit-id: ca0452ff4511c946946a2208b44471b1e2c6fc43 --- test/test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index b9aa484f96..e6d37b8277 100644 --- a/test/test.js +++ b/test/test.js @@ -102,7 +102,7 @@ if (window.document && window.require) { equal((lodashModule || {}).moduleName, 'lodash'); } else { - skipTest() + skipTest(); } }); @@ -110,7 +110,7 @@ if (window.document && window.require) { equal((underscoreModule || {}).moduleName, 'underscore'); } else { - skipTest() + skipTest(); } }); @@ -1557,6 +1557,7 @@ (function() { test('should allow a falsey arguments', function() { var funcs = _.without.apply(_, [_.functions(_)].concat([ + '_', '_iteratorTemplate', '_shimKeys', 'after', From e60bbc2fb74c5f99f2bffa2c6f10defe6ff89f47 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 21 Aug 2012 01:32:41 -0700 Subject: [PATCH 15/19] Bump to v0.5.2. Former-commit-id: 43998ef8cf3cbdb9205d702d950f9f59febc420b --- README.md | 93 ++++++++++++++++++++++++++++----------------------- doc/README.md | 4 +-- doc/parse.php | 2 +- lodash.js | 10 +++--- lodash.min.js | 4 +-- package.json | 2 +- 6 files changed, 62 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 8c1684a151..f166634aef 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# Lo-Dash v0.5.1 +# Lo-Dash v0.5.2 -A drop-in replacement[*](https://github.com/bestiejs/lodash/wiki/Drop-in-Disclaimer) for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), delivering [performance](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#resolved-underscorejs-issues-20), and [additional features](https://github.com/bestiejs/lodash#features). +A drop-in replacement[*](https://github.com/bestiejs/lodash/wiki/Drop-in-Disclaimer) for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), delivering [performance](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#resolved-underscorejs-issues-30), and [additional features](https://github.com/bestiejs/lodash#features). 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. ## Download - * [Development source](https://raw.github.com/bestiejs/lodash/v0.5.1/lodash.js) - * [Production source](https://raw.github.com/bestiejs/lodash/v0.5.1/lodash.min.js) + * [Development source](https://raw.github.com/bestiejs/lodash/v0.5.2/lodash.js) + * [Production source](https://raw.github.com/bestiejs/lodash/v0.5.2/lodash.min.js) * CDN copies of ≤ [v0.5.1](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.5.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 @@ -31,8 +31,8 @@ For more information check out these screencasts over Lo-Dash: ## Features * AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.) - * [_.bind](http://lodash.com/docs#bind) supports *"lazy"* binding - * [_.clone](http://lodash.com/docs#clone) supports *"deep"* cloning + * [_.bind](http://lodash.com/docs#bind) supports *“lazy”* binding + * [_.clone](http://lodash.com/docs#clone) supports *“deep”* cloning * [_.countBy](http://lodash.com/docs#countBy) as a compainion function for [_.groupBy](http://lodash.com/docs#groupBy) and [_.sortBy](http://lodash.com/docs#sortBy) * [_.debounce](http://lodash.com/docs#debounce)’ed functions match [_.throttle](http://lodash.com/docs#throttle)’ed functions’ return value behavior * [_.drop](http://lodash.com/docs#drop) for the inverse functionality of [_.pick](http://lodash.com/docs#pick) @@ -41,7 +41,7 @@ For more information check out these screencasts over Lo-Dash: * [_.forOwn](http://lodash.com/docs#forOwn) for iterating over an object’s own properties * [_.groupBy](http://lodash.com/docs#groupBy), [_.sortedIndex](http://lodash.com/docs#sortedIndex), and [_.uniq](http://lodash.com/docs#uniq) accept a `thisArg` argument * [_.indexOf](http://lodash.com/docs#indexOf) and [_.lastIndexOf](http://lodash.com/docs#lastIndexOf) accept a `fromIndex` argument - * [_.merge](http://lodash.com/docs#merge) for a *"deep"* [_.extend](http://lodash.com/docs#extend) + * [_.merge](http://lodash.com/docs#merge) for a *“deep”* [_.extend](http://lodash.com/docs#extend) * [_.partial](http://lodash.com/docs#partial) for partial application without `this` binding * [_.sortBy](http://lodash.com/docs#sortBy) performs a [stable](http://en.wikipedia.org/wiki/Sorting_algorithm#Stability) sort * [_.template](http://lodash.com/docs#template) utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging @@ -92,7 +92,7 @@ lodash underscore Custom builds may be created in three ways: 1. Use the `category` argument to pass the categories of methods to include in the build.
    - Valid categories are *"arrays"*, *"chaining"*, *"collections"*, *"functions"*, *"objects"*, and *"utilities"*. + Valid categories are *“arrays”*, *“chaining”*, *“collections”*, *“functions”*, *“objects”*, and *“utilities”*. ```bash lodash category=collections,functions lodash category="collections, functions" @@ -167,39 +167,41 @@ require({ }); ``` -## Resolved Underscore.js issues (20+) +## Resolved Underscore.js issues (30+) - * 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.5.1/test/test.js#L552-558)] - * Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L499-509)] - * Ensure *"Arrays"* methods allow falsey `array` arguments [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1495-1533)] - * 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.5.1/test/test.js#L511-529)] - * Ensure templates compiled with errors are inspectable [[#666](https://github.com/documentcloud/underscore/issues/666), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1240-1243)] - * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L563-588)] + * 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.5.2/test/test.js#L551-557)] + * Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L499-509)] + * Ensure *“Arrays”*, “Collections”, and “Objects” methods allow falsey arguments [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1558-1593)] + * 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.5.2/test/test.js#L511-529)] + * Ensure templates compiled with errors are inspectable [[#666](https://github.com/documentcloud/underscore/issues/666), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1299-1302)] + * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L562-587)] * 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.5.1/test/test.js#L117-123)] - * 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.5.1/test/test.js#L101-115)] - * `_(…)` should return passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L135-138)] - * `_.clone` should allow `deep` cloning [[#595](https://github.com/documentcloud/underscore/pull/595), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L205-220)] - * `_.contains` should work with strings [[#667](https://github.com/documentcloud/underscore/pull/667), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L275-284)] - * `_.escape` should return an empty string when passed `null` or `undefined` [[#427](https://github.com/documentcloud/underscore/issues/427), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L375-378)] - * `_.extend` should recursively extend objects [[#379](https://github.com/documentcloud/underscore/pull/379), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L892-914)] - * `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L494-497)] - * `_.forEach` should allow exiting iteration early [[#211](https://github.com/documentcloud/underscore/issues/211), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L590-609)] - * `_.groupBy` should add values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L624-631)] - * `_.isEmpty` and `_.size` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L724-729)] - * `_.isEqual` should return `true` for like-objects from different documents [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L765-785)] - * `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L793-805)] - * `_.isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L813-815)] - * `_.keys` and `_.size` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [#653](https://github.com/documentcloud/underscore/issues/653), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L825-827)] + * 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.5.2/test/test.js#L117-123)] + * 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.5.2/test/test.js#L101-115)] + * `_(…)` should return passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L135-138)] + * `_.clone` should allow `deep` cloning [[#595](https://github.com/documentcloud/underscore/pull/595), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L205-220)] + * `_.contains` should work with strings [[#667](https://github.com/documentcloud/underscore/pull/667), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L275-284)] + * `_.escape` should return an empty string when passed `null` or `undefined` [[#427](https://github.com/documentcloud/underscore/issues/427), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L375-378)] + * `_.extend` should recursively extend objects [[#379](https://github.com/documentcloud/underscore/pull/379), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L952-974)] + * `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L494-497)] + * `_.forEach` should allow exiting iteration early [[#211](https://github.com/documentcloud/underscore/issues/211), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L589-608)] + * `_.groupBy` should add values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L623-630)] + * `_.isElement` should use strict equality for its duck type check [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L704-713)] + * `_.isEmpty` and `_.size` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L740-745)] + * `_.isEqual` should return `true` for like-objects from different documents [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L781-801)] + * `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L809-821)] + * `_.isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L829-831)] + * `_.keys` and `_.size` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [#653](https://github.com/documentcloud/underscore/issues/653), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L885-887)] * `_.once` should free the given function for garbage collection [[#693](https://github.com/documentcloud/underscore/pull/693)] - * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1050-1053)] - * `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1061-1075)] - * `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1120-1122)] - * `_.size` shouldn’t error on falsey values [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1124-1131)] - * `_.sortedIndex` should support arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1210-1219)] - * `_.template` should not augment the `options` object [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1234-1238)] - * `_.throttle` should work when called in a loop [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1330-1340)] - * `_.zipObject` should accept less than two arguments [[test](https://github.com/bestiejs/lodash/blob/v0.5.1/test/test.js#L1457-1459)] + * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1110-1113)] + * `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1121-1135)] + * `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1179-1181)] + * `_.size` shouldn’t error on falsey values [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1183-1190)] + * `_.sortedIndex` should support arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1269-1278)] + * `_.template` should not augment the `options` object [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1293-1297)] + * `_.throttle` should work when called in a loop [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1389-1399)] + * `_.toArray` uses custom `toArray` methods of arrays and strings [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1426-1434)] + * `_.zipObject` should accept less than two arguments [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1520-1522)] ## Optimized methods (50+) @@ -263,6 +265,13 @@ require({ ## Release Notes +### v0.5.2 + + * Ensured `_.isElement` uses strict equality for its duck type check + * Ensured `_.isObject` returns a boolean value + * Ensured `_.template` and *“Objects”* methods don’t error when passed falsey values + * Made `_.template` generate less unused code in compiled templates + ### v0.5.1 * Ensured `_.bind` correctly appends array arguments to partially applied arguments in older browsers @@ -276,10 +285,10 @@ require({ * Added support for exiting `_.forEach`, `_.forIn`, and `_.forOwn` early by returning `false` in the `callback` * Added support for jQuery/MooTools DOM query collections to `_.isEmpty` and `_.size` * Ensured development build works with IE conditional compilation enabled - * Ensured `_.clone` doesn't clone functions, DOM nodes, `arguments` objects, and objects created by constructors other than `Object` - * Ensured `_.filter`’s `callback` can't modify result values + * Ensured `_.clone` doesn’t clone functions, DOM nodes, `arguments` objects, and objects created by constructors other than `Object` + * Ensured `_.filter`’s `callback` can’t modify result values * Ensured `_.isEmpty`, `_.isEquals`, and `_.size` support `arguments` objects - * Ensured `_.isEqual` doesn't inspect DOM nodes, works with objects from other documents, and calls custom `isEqual` methods before checking strict equality + * Ensured `_.isEqual` doesn’t inspect DOM nodes, works with objects from other documents, and calls custom `isEqual` methods before checking strict equality * Ensured `_.once` frees the given function for garbage collection * Ensured `_.sortBy` performs a stable sort * Ensured `reEvaluateDelimiter` is assigned when `_.templateSettings.evaluate` is undefined @@ -290,7 +299,7 @@ The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/C ## BestieJS -Lo-Dash is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. +Lo-Dash is part of the BestieJS *“Best in Class”* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. ## Author diff --git a/doc/README.md b/doc/README.md index 8e89b6f2c7..54e2ed1cd0 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v0.5.1 +# Lo-Dash v0.5.2 @@ -2404,7 +2404,7 @@ _.times(3, function() { this.grantWish(); }, genie); ### `_.toArray(collection)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2323 "View in source") [Ⓣ][1] -Converts the `collection`, into an array. Useful for converting the `arguments` object. +Converts the `collection`, to an array. Useful for converting the `arguments` object. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to convert. diff --git a/doc/parse.php b/doc/parse.php index 6407b48e17..5e38f29d5b 100644 --- a/doc/parse.php +++ b/doc/parse.php @@ -21,7 +21,7 @@ // generate Markdown $markdown = docdown(array( 'path' => '../' . $file, - 'title' => 'Lo-Dash v0.5.1', + 'title' => 'Lo-Dash v0.5.2', 'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js' )); diff --git a/lodash.js b/lodash.js index 6bdb56b783..3c5448223d 100644 --- a/lodash.js +++ b/lodash.js @@ -1,5 +1,5 @@ /*! - * Lo-Dash v0.5.1 + * Lo-Dash v0.5.2 * Copyright 2012 John-David Dalton * Based on Underscore.js 1.3.3, copyright 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. * @@ -399,7 +399,6 @@ ' value = iteratee[index];\n' + ' <%= objectBranch.inLoop %>;\n' + ' <% if (useHas) { %>}<% } %>' + - ' <% } else { %>\n' + // Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 // (if the prototype or a property on the prototype has been set) @@ -407,6 +406,7 @@ // value to `true`. Because of this Lo-Dash standardizes on skipping // the the `prototype` property of functions regardless of its // [[Enumerable]] value. + ' <% } else { %>\n' + ' if (!(skipProto && index == \'prototype\')<% if (useHas) { %> &&\n' + ' hasOwnProperty.call(iteratee, index)<% } %>) {\n' + ' value = iteratee[index];\n' + @@ -2307,7 +2307,7 @@ }); /** - * Converts the `collection`, into an array. Useful for converting the + * Converts the `collection`, to an array. Useful for converting the * `arguments` object. * * @static @@ -3906,7 +3906,7 @@ } // provide the compiled function's source via its `toString` method, in // supported environments, or the `source` property as a convenience for - // build time precompilation + // inlining compiled templates during the build process result.source = text; return result; } @@ -4061,7 +4061,7 @@ * @memberOf _ * @type String */ - lodash.VERSION = '0.5.1'; + lodash.VERSION = '0.5.2'; // assign static methods lodash.after = after; diff --git a/lodash.min.js b/lodash.min.js index e8a27f2b5e..3ba864b0f9 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,5 +1,5 @@ /*! - Lo-Dash 0.5.1 lodash.com/license + Lo-Dash 0.5.2 lodash.com/license Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE */ ;(function(e,t){"use strict";function s(e){return new o(e)}function o(e){if(e&&e._wrapped)return e;this._wrapped=e}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||30),s=i?{}:e;if(i)for(var o=t-1;++o-1&&j===j>>>0&&T(y.splice)))return!j",i:{l:"return false"}}),rn=dt?function(e){var t=typeof e;return"function"==t&&at.call(e,"prototype")?Kt(e):e&&Ft[t]?dt(e):[]}:Kt,sn=a(zt,{a:"l,ee,O,ff",q:"var J,L,Q,gg,dd=O==U;if(!dd)ff=[];for(var B=1,C=dd?2:arguments.length;B-1"},i:"if(y===hh)return true"}),an=a(qt,Rt),fn=a(qt,Ut),ln=a(qt,Wt),cn=a(qt,Xt,{j:"",i:"if(a(y,g,b))return y"}),hn=a(qt,Xt),pn=a(qt,Rt,{i:"o=a(y,g,b);(e.call(s,o)?s[o]:s[o]=[]).push(y)" }),dn=a($t,{a:"b,V",q:"var A=u.call(arguments,2),S=typeof V=='function'",i:{b:"s[g]=(S?V:y[V]).apply(y,A)",l:"s"+(Pt?"[m]=":".push")+"((S?V:y[V]).apply(y,A))"}}),vn=a(qt,$t),mn=a($t,{a:"b,bb",i:{b:"s[g]=y[bb]",l:"s"+(Pt?"[m]=":".push")+"(y[bb])"}}),gn=a({a:"b,a,z,w",j:"z",q:"var W=arguments.length<3;if(w)a=i(a,w)",d:{b:"if(W)s=b[++g]"},i:{b:"s=a(s,y,g,b)",l:"s=W?(W=false,y):a(s,y,g,b)"}}),yn=a(qt,Wt,{i:"!"+Wt.i}),bn=a(qt,Ut,{j:"false",i:Ut.i.replace("!","")}),wn=a(qt,Rt,$t,{i:{b:"s[g]={a:a(y,g,b),b:g,d:y}" -,l:"s"+(Pt?"[m]=":".push")+"({a:a(y,g,b),b:g,d:y})"},e:"s.sort(I);j=s.length;while(j--)s[j]=s[j].d"}),En=a(Wt,{a:"b,aa",q:"var Z,o,q,r=[];K(aa,function(y,o){r.push(o)});var cc=r.length",i:"for(Z=true,q=0;q1){for(var g=1;ge?t():function(){if(1>--e)return t.apply +,l:"s"+(Pt?"[m]=":".push")+"({a:a(y,g,b),b:g,d:y})"},e:"s.sort(I);j=s.length;while(j--)s[j]=s[j].d"}),En=a(Wt,{a:"b,aa",q:"var Z,o,q,r=[];K(aa,function(y,o){r.push(o)});var cc=r.length",i:"for(Z=true,q=0;q1){for(var g=1;ge?t():function(){if(1>--e)return t.apply (this,arguments)}},s.bind=M,s.bindAll=Sn,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=E,s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++nC(t,n)&&fn(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke=dn,s.isArguments=b,s.isArray=Jt,s.isBoolean=function(e){return e===n||e===i||lt. diff --git a/package.json b/package.json index 49f864700d..47f2ef0a9a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "0.5.1", + "version": "0.5.2", "description": "A drop-in replacement for Underscore.js delivering performance, bug fixes, and additional features.", "homepage": "http://lodash.com", "main": "lodash", From 5b9271ccfeffcb65981cb4fdc9f12eb46a36d1f9 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 21 Aug 2012 01:59:56 -0700 Subject: [PATCH 16/19] Add isType benchmarks. Former-commit-id: 875af51200d60eb6105eb36ab090e9f307a15340 --- perf/perf.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/perf/perf.js b/perf/perf.js index 3b8534830d..3148292385 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -154,7 +154,9 @@ belt = this.name == "Lo-Dash" ? lodash : _;\ \ var index,\ + date = new Date,\ limit = 20,\ + regexp = /x/,\ object = {},\ objects = Array(limit),\ numbers = Array(limit),\ @@ -941,6 +943,36 @@ /*--------------------------------------------------------------------------*/ + suites.push( + Benchmark.Suite('`_.isArguments`, `_.isDate`, `_.isFunction`, `_.isNumber`, `_.isRegExp`') + .add('Lo-Dash', '\ + lodash.isArguments(arguments);\ + lodash.isArguments(object);\ + lodash.isDate(date);\ + lodash.isDate(object);\ + lodash.isFunction(lodash);\ + lodash.isFunction(object);\ + lodash.isNumber(1);\ + lodash.isNumber(object);\ + lodash.isRegExp(regexp);\ + lodash.isRegExp(object);' + ) + .add('Underscore', '\ + _.isArguments(arguments);\ + _.isArguments(object);\ + _.isDate(date);\ + _.isDate(object);\ + _.isFunction(_);\ + _.isFunction(object);\ + _.isNumber(1);\ + _.isNumber(object);\ + _.isRegExp(regexp);\ + _.isRegExp(object);' + ) + ); + + /*--------------------------------------------------------------------------*/ + suites.push( Benchmark.Suite('`_.keys` (uses native `Object.keys` if available)') .add('Lo-Dash', '\ From feeb38293d4c40fe1eefb102401c48f21f4f4f4b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 21 Aug 2012 02:13:53 -0700 Subject: [PATCH 17/19] Update cdnjs link to v0.5.2 in README.md. Former-commit-id: e519a03ad9016f8aebd2c703f29bb350bcd442f1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f166634aef..8b603ae1fa 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Lo-Dash’s performance is gained by avoiding slower native methods, instead opt * [Development source](https://raw.github.com/bestiejs/lodash/v0.5.2/lodash.js) * [Production source](https://raw.github.com/bestiejs/lodash/v0.5.2/lodash.min.js) - * CDN copies of ≤ [v0.5.1](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.5.1/lodash.min.js) are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/) + * CDN copies of ≤ [v0.5.2](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.5.2/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 ## Dive in From cc150ff9d2e37d98bfe198e22570f4417c3a036b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 21 Aug 2012 02:31:40 -0700 Subject: [PATCH 18/19] Cleanup test.js and README.md. Former-commit-id: af3372f58ecf8d979d22c88193589857c06ff7c1 --- README.md | 5 ++--- test/test.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8b603ae1fa..b54b932970 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ require({ * 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.5.2/test/test.js#L551-557)] * Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L499-509)] - * Ensure *“Arrays”*, “Collections”, and “Objects” methods allow falsey arguments [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1558-1593)] + * Ensure *“Arrays”*, “Collections”, and “Objects” methods don’t error when passed falsey arguments [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1558-1593)] * 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.5.2/test/test.js#L511-529)] * Ensure templates compiled with errors are inspectable [[#666](https://github.com/documentcloud/underscore/issues/666), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1299-1302)] * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L562-587)] @@ -196,7 +196,6 @@ require({ * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1110-1113)] * `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1121-1135)] * `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1179-1181)] - * `_.size` shouldn’t error on falsey values [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1183-1190)] * `_.sortedIndex` should support arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1269-1278)] * `_.template` should not augment the `options` object [[test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1293-1297)] * `_.throttle` should work when called in a loop [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/v0.5.2/test/test.js#L1389-1399)] @@ -269,7 +268,7 @@ require({ * Ensured `_.isElement` uses strict equality for its duck type check * Ensured `_.isObject` returns a boolean value - * Ensured `_.template` and *“Objects”* methods don’t error when passed falsey values + * Ensured `_.template` and *“Objects”* methods don’t error when passed falsey arguments * Made `_.template` generate less unused code in compiled templates ### v0.5.1 diff --git a/test/test.js b/test/test.js index e6d37b8277..ad61def973 100644 --- a/test/test.js +++ b/test/test.js @@ -1555,7 +1555,7 @@ QUnit.module('lodash methods'); (function() { - test('should allow a falsey arguments', function() { + test('should allow falsey arguments', function() { var funcs = _.without.apply(_, [_.functions(_)].concat([ '_', '_iteratorTemplate', @@ -1588,7 +1588,7 @@ } }); - ok(pass, methodName + ' allows a falsey arguments'); + ok(pass, methodName + ' allows falsey arguments'); }); }); }()); From a82a364c2293f74fcb321113ed5947fb1e3c7acf Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 21 Aug 2012 21:21:24 -0700 Subject: [PATCH 19/19] Update dependencies in build.js. Former-commit-id: 020a52bdd604b55b078637aeb59e2e53483c950d --- build.js | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/build.js b/build.js index 8be41afc69..c87251d168 100755 --- a/build.js +++ b/build.js @@ -150,31 +150,31 @@ /** Used to track function dependencies */ var dependencyMap = { 'after': [], - 'bind': [], - 'bindAll': ['bind', 'functions'], + 'bind': ['isFunction'], + 'bindAll': ['bind', 'isFunction'], 'chain': ['mixin'], - 'clone': ['extend', 'forIn', 'forOwn', 'isArguments'], + 'clone': ['extend', 'forIn', 'forOwn', 'isArguments', 'isFunction'], 'compact': [], 'compose': [], 'contains': [], 'countBy': [], 'debounce': [], - 'defaults': [], + 'defaults': ['isArguments'], 'defer': [], 'delay': [], 'difference': ['indexOf'], - 'drop': ['indexOf'], + 'drop': ['indexOf', 'isArguments'], 'escape': [], 'every': ['identity'], - 'extend': [], + 'extend': ['isArguments'], 'filter': ['identity'], 'find': [], 'first': [], 'flatten': ['isArray'], 'forEach': [], - 'forIn': [], - 'forOwn': [], - 'functions': [], + 'forIn': ['isArguments'], + 'forOwn': ['isArguments'], + 'functions': ['isArguments', 'isFunction'], 'groupBy': [], 'has': [], 'identity': [], @@ -187,8 +187,8 @@ 'isBoolean': [], 'isDate': [], 'isElement': [], - 'isEmpty': ['isArguments'], - 'isEqual': ['isArguments'], + 'isEmpty': ['isArguments', 'isFunction'], + 'isEqual': ['isArguments', 'isFunction'], 'isFinite': [], 'isFunction': [], 'isNaN': [], @@ -198,13 +198,13 @@ 'isRegExp': [], 'isString': [], 'isUndefined': [], - 'keys': [], + 'keys': ['isArguments'], 'last': [], 'lastIndexOf': [], 'map': ['identity'], 'max': [], 'memoize': [], - 'merge': ['isArray', 'forIn'], + 'merge': ['isArguments', 'isArray', 'forIn'], 'min': [], 'mixin': ['forEach', 'functions'], 'noConflict': [], @@ -217,9 +217,9 @@ 'reduceRight': ['keys'], 'reject': ['identity'], 'rest': [], - 'result': [], + 'result': ['isFunction'], 'shuffle': [], - 'size': ['isArguments', 'keys'], + 'size': ['isArguments', 'isFunction', 'keys'], 'some': ['identity'], 'sortBy': [], 'sortedIndex': ['bind'], @@ -227,11 +227,11 @@ 'template': ['escape'], 'throttle': [], 'times': [], - 'toArray': ['values'], + 'toArray': ['isFunction', 'values'], 'union': ['indexOf'], 'uniq': ['identity', 'indexOf'], 'uniqueId': [], - 'values': [], + 'values': ['isArguments'], 'where': ['forIn'], 'without': ['indexOf'], 'wrap': [], @@ -531,6 +531,17 @@ return removeFromCreateIterator(source, funcName); } + /** + * Removes the `_.isFunction` fallback from `source`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the source with the `isFunction` fallback removed. + */ + function removeIsFunctionFallback(source) { + return source.replace(/(?:\s*\/\/.*)*\s*if *\(isFunction\(\/x\/[\s\S]+?};\s*}/, ''); + } + /** * Removes the `_.isArguments` fallback from `source`. * @@ -1030,6 +1041,9 @@ if (isRemoved(source, 'isArray')) { source = removeVar(source, 'nativeIsArray'); } + if (isRemoved(source, 'isFunction')) { + source = removeIsFunctionFallback(source); + } if (isRemoved(source, 'keys')) { source = removeFunction(source, 'shimKeys'); }