From 8a5eb89aa879e977812570d251987af222a8a26e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 25 May 2012 15:15:16 -0400 Subject: [PATCH 01/19] Ensure `_.find` returns `undefined`when a value cannot be found. [closes #15] Former-commit-id: e6dc89f98a1df81e1b1d67c5e8f5725e4df3bc5a --- lodash.js | 1 + test/test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lodash.js b/lodash.js index cc73224bd0..bfadc4c4d2 100644 --- a/lodash.js +++ b/lodash.js @@ -585,6 +585,7 @@ * // => 2 */ var find = createIterator(baseIteratorOptions, { + 'init': '', 'inLoop': 'if (callback(collection[index], index, collection)) return collection[index]' }); diff --git a/test/test.js b/test/test.js index 2036fa49b5..9eb1b18441 100644 --- a/test/test.js +++ b/test/test.js @@ -174,6 +174,22 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.find'); + + (function() { + var array = [1, 2, 3, 4]; + + test('should return found `value`', function() { + equal(_.find(array, function(n) { return n > 2; }), 3); + }); + + test('should return `undefined` if `value` is not found', function() { + equal(_.find(array, function(n) { return n == 5; }), undefined); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.flatten'); (function() { From 5da03cac79499e4f921b3768616bd55f968eae49 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 25 May 2012 15:16:39 -0400 Subject: [PATCH 02/19] Add pseudo private property in preparation for mobile builds. Former-commit-id: d5812d968b7694c9778f1be7efa8d05f95789ec8 --- lodash.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index bfadc4c4d2..42240a7dd0 100644 --- a/lodash.js +++ b/lodash.js @@ -3189,7 +3189,8 @@ lodash.take = first; lodash.unique = uniq; - // add pseudo private template used and removed during the build process + // add pseudo privates used and removed during the build process + lodash._createIterator = createIterator; lodash._iteratorTemplate = iteratorTemplate; /*--------------------------------------------------------------------------*/ From 06ffa93bd04d953e5368bf886348016bb03cdc32 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 25 May 2012 15:18:03 -0400 Subject: [PATCH 03/19] Update minified build and docs. Former-commit-id: f9c076e5254c563c714bccf7cd5d65b6716cd427 --- doc/README.md | 160 +++++++++++++++++++++++++------------------------- lodash.min.js | 52 ++++++++-------- 2 files changed, 106 insertions(+), 106 deletions(-) diff --git a/doc/README.md b/doc/README.md index 513b834b59..021fe5a462 100644 --- a/doc/README.md +++ b/doc/README.md @@ -145,7 +145,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3089 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3090 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -157,7 +157,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1618 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1619 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -185,7 +185,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1669 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1670 "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`. @@ -232,7 +232,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1740 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1741 "View in source") [Ⓣ][1] Binds methods on the `object` to the object, overwriting the non-bound method. If no method names are provided, all the function properties of the `object` will be bound. @@ -264,7 +264,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3041 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3042 "View in source") [Ⓣ][1] Wraps the value in a `lodash` chainable object. @@ -298,7 +298,7 @@ var youngest = _.chain(stooges) ### `_.clone(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2066 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2067 "View in source") [Ⓣ][1] Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned. @@ -322,7 +322,7 @@ _.clone({ 'name': 'moe' }); ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L880 "View in source") [Ⓣ][1] Produces a new array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -346,7 +346,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1773 "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 thefunctions `f()`, `g()`, and `h()` produces `f(g(h()))`. @@ -398,7 +398,7 @@ _.contains([1, 2, 3], 3); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1805 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1806 "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. @@ -424,7 +424,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, defaults1, defaults2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2089 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2090 "View in source") [Ⓣ][1] Assigns missing properties in `object` with default values from the defaults objects. As soon as a property is set, additional defaults of the same property will be ignored. @@ -450,7 +450,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'lots' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1871 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments are passed to `func` when it is invoked. @@ -475,7 +475,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1851 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments are passed to `func` when it is invoked. @@ -502,7 +502,7 @@ _.delay(log, 1000, 'logged later'); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L908 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L909 "View in source") [Ⓣ][1] Produces a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -527,7 +527,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2737 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2738 "View in source") [Ⓣ][1] Escapes a string for insertion into HTML, replacing `&`, `<`, `"`, `'`, and `/` characters. @@ -577,7 +577,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2108 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2109 "View in source") [Ⓣ][1] Copies enumerable properties from the source objects to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -654,7 +654,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#L941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L942 "View in source") [Ⓣ][1] Gets the first value of the `array`. Pass `n` to return the first `n` values of the `array`. @@ -680,7 +680,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L963 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L964 "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. @@ -708,7 +708,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.forEach(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L613 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L614 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each value in the `collection`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -737,7 +737,7 @@ _([1, 2, 3]).forEach(function(num) { alert(num); }).join(','); ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2125 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2126 "View in source") [Ⓣ][1] Produces a sorted array of the properties, own and inherited, of `object` that have function values. @@ -761,7 +761,7 @@ _.functions(_); ### `_.groupBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1005 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1006 "View in source") [Ⓣ][1] Splits a `collection` into sets, grouped by the result of running each value through `callback`. The `callback` is invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to group by. @@ -793,7 +793,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2148 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2149 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -818,7 +818,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2764 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2765 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -843,7 +843,7 @@ moe === _.identity(moe); ### `_.indexOf(array, value [, isSorted=false])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1091 "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. @@ -869,7 +869,7 @@ _.indexOf([1, 2, 3], 2); ### `_.initial(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1124 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1125 "View in source") [Ⓣ][1] Gets all but the last value of the `array`. Pass `n` to exclude the last `n` values from the result. @@ -895,7 +895,7 @@ _.initial([5, 4, 3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1142 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1143 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays. @@ -919,7 +919,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.invoke(array, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1175 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1176 "View in source") [Ⓣ][1] Calls the method named by `methodName` for each value of the `collection`. Additional arguments will be passed to each invoked method. @@ -945,7 +945,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2169 "View in source") [Ⓣ][1] Checks if a `value` is an `arguments` object. @@ -972,7 +972,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2194 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2195 "View in source") [Ⓣ][1] Checks if a `value` is an array. @@ -999,7 +999,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2211 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2212 "View in source") [Ⓣ][1] Checks if a `value` is a boolean *(`true` or `false`)* value. @@ -1023,7 +1023,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2228 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2229 "View in source") [Ⓣ][1] Checks if a `value` is a date. @@ -1047,7 +1047,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2245 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2246 "View in source") [Ⓣ][1] Checks if a `value` is a DOM element. @@ -1071,7 +1071,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2266 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2267 "View in source") [Ⓣ][1] Checks if a `value` is empty. Arrays or strings with a length of `0` and objects with no enumerable own properties are considered "empty". @@ -1098,7 +1098,7 @@ _.isEmpty({}); ### `_.isEqual(a, b [, stack])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2301 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -1130,7 +1130,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2452 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2453 "View in source") [Ⓣ][1] Checks if a `value` is a finite number. @@ -1160,7 +1160,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2469 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [Ⓣ][1] Checks if a `value` is a function. @@ -1184,7 +1184,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2520 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2521 "View in source") [Ⓣ][1] Checks if a `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. @@ -1217,7 +1217,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2542 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2543 "View in source") [Ⓣ][1] Checks if a `value` is `null`. @@ -1244,7 +1244,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2559 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2560 "View in source") [Ⓣ][1] Checks if a `value` is a number. @@ -1268,7 +1268,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2490 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2491 "View in source") [Ⓣ][1] Checks if a `value` is the language type of Object. *(e.g. arrays, functions, objects, regexps, `new Number(0)*`, and `new String('')`) @@ -1295,7 +1295,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2576 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2577 "View in source") [Ⓣ][1] Checks if a `value` is a regular expression. @@ -1319,7 +1319,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2594 "View in source") [Ⓣ][1] Checks if a `value` is a string. @@ -1343,7 +1343,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2610 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2611 "View in source") [Ⓣ][1] Checks if a `value` is `undefined`. @@ -1367,7 +1367,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2627 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2628 "View in source") [Ⓣ][1] Produces an array of the `object`'s enumerable own property names. @@ -1391,7 +1391,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.last(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1206 "View in source") [Ⓣ][1] Gets the last value of the `array`. Pass `n` to return the lasy `n` values of the `array`. @@ -1417,7 +1417,7 @@ _.last([5, 4, 3, 2, 1]); ### `_.lastIndexOf(array, value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1225 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1226 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. @@ -1442,7 +1442,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); ### `_.map(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L639 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L640 "View in source") [Ⓣ][1] Produces a new array of values by mapping each value in the `collection` through a transformation `callback`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1471,7 +1471,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#L1262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1263 "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 invoked with `3` arguments; *(value, index, array)*. @@ -1503,7 +1503,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1894 "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. @@ -1529,7 +1529,7 @@ var fibonacci = _.memoize(function(n) { ### `_.min(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "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 invoked with `3` arguments; *(value, index, array)*. @@ -1555,7 +1555,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2790 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2791 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1585,7 +1585,7 @@ _('larry').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2821 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2822 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1605,7 +1605,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1919 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1920 "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. @@ -1631,7 +1631,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1953 "View in source") [Ⓣ][1] Creates a new function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the partially applied function. This method is similar `bind`, except it does **not** alter the `this` binding. @@ -1658,7 +1658,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2650 "View in source") [Ⓣ][1] Creates an object composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. @@ -1683,7 +1683,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L661 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L662 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all values in a `collection`. @@ -1714,7 +1714,7 @@ _.pluck(stooges, 'name'); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1365 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1366 "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. @@ -1752,7 +1752,7 @@ _.range(0); ### `_.reduce(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L691 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L692 "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 the `thisArg` value, if one is passed. The `callback` is invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*. @@ -1779,7 +1779,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#L731 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L732 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*. @@ -1807,7 +1807,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L784 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L785 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1833,7 +1833,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#L1401 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1402 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of the `array`. Pass `n` to exclude the first `n` values from the result. @@ -1859,7 +1859,7 @@ _.rest([5, 4, 3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2851 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2852 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If the property is a function it will be invoked and its result returned, else the property value is returned. @@ -1894,7 +1894,7 @@ _.result(object, 'stuff'); ### `_.shuffle(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1419 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1420 "View in source") [Ⓣ][1] Produces a new array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1918,7 +1918,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2688 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2689 "View in source") [Ⓣ][1] Gets the size of a `value` by returning `value.length` if `value` is a string or array, or the number of own enumerable properties if `value` is an object. @@ -1948,7 +1948,7 @@ _.size('curly'); ### `_.some(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L808 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L809 "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 invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1974,7 +1974,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1048 "View in source") [Ⓣ][1] Produces a new sorted array, ranked in ascending order by the results of running each value of a `collection` through `callback`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -2003,7 +2003,7 @@ _.sortBy([1, 2, 3, 4, 5, 6], function(num) { return this.sin(num); }, Math); ### `_.sortedIndex(array, value [, callback])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1453 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1454 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into the `collection` in order to maintain the sort order of the `collection`. If `callback` is passed, it will be executed for each value in the `collection` to compute their sort ranking. The `callback` is invoked with `1` argument; *(value)*. @@ -2029,7 +2029,7 @@ _.sortedIndex([10, 20, 30, 40, 50], 35); ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2716 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2717 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The primary purpose of this method is to "tap into" a method chain, in order to performoperations on intermediate results within the chain. @@ -2059,7 +2059,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2911 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2912 "View in source") [Ⓣ][1] A JavaScript micro-templating method, similar to John Resig's implementation. Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2119,7 +2119,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' }); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1988 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1989 "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, `func` will also be called on the trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2144,7 +2144,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2988 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2989 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is invoked with `1` argument; *(index)*. @@ -2166,7 +2166,7 @@ _.times(3, function() { genie.grantWish(); }); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L827 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L828 "View in source") [Ⓣ][1] Converts the `collection`, into an array. Useful for converting the `arguments` object. @@ -2190,7 +2190,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1486 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1487 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays. @@ -2214,7 +2214,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1521 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1522 "View in source") [Ⓣ][1] Produces 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 value of `array` is passed through a transformation `callback` before uniqueness is computed. The `callback` is invoked with `3` arguments; *(value, index, array)*. @@ -2240,7 +2240,7 @@ _.uniq([1, 2, 1, 3, 1, 4]); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3011 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3012 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2264,7 +2264,7 @@ _.uniqueId('contact_'); ### `_.values(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L855 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L856 "View in source") [Ⓣ][1] Produces an array of enumerable own property values of the `collection`. @@ -2288,7 +2288,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1556 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1557 "View in source") [Ⓣ][1] Produces a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2313,7 +2313,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(func, wrapper [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2040 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2041 "View in source") [Ⓣ][1] Create a new function that passes the `func` function to the `wrapper` function as its first argument. Additional arguments are appended to those passed to the `wrapper` function. @@ -2343,7 +2343,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1586 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1587 "View in source") [Ⓣ][1] Merges together the values of each of the arrays with the value at the corresponding position. 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. @@ -2374,7 +2374,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3059 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3060 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2395,7 +2395,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3076 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3077 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. diff --git a/lodash.min.js b/lodash.min.js index 22754424b9..bd3ba9bd41 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -2,29 +2,29 @@ Lo-Dash 0.2.1 lodash.com/license Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE */ -;(function(u,n){"use strict";function R(a){return"[object Arguments]"==i.call(a)}function b(a){return new p(a)}function p(a){if(a&&a._wrapped)return a;this._wrapped=a}function k(){for(var a,c,d,j=-1,b=arguments.length,e={e:"",f:"",k:"",q:"",c:{d:"",m:"++l/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"object"};var sa=Function("n","var __p;with(n){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" -),t={a:"f,d,x",k:"f",q:"if(!d){d=k}else if(x){d=c(d,x)}",j:"d(f[l],l,f)"},Y={k:"z",j:"if(!d(f[l],l,f))return!r"},Z={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ua?c():function(){if(1>--a)return c.apply(this,arguments)}},b.bind=v,b.bindAll=function(a){var c=arguments,d=1;1==c.length&&(d=0,c=O(a));for(var b=c.length;dx(f,a[c])&&b.push(a[c]);return b},b.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(e,c)&&$(f,function(a){return-1arguments.length&&(c=a||0,a=0);for(var b=-1,f=Math.max(Math.ceil((c-a)/d),0),e=Array(f);++bd?1:0}),"b")},b.sortedIndex=ha,b.tap=function(a,c){return c(a),a} -,b.template=function(a,c,d){d||(d={});var j;j=b.templateSettings;var f=d.escape,e=d.evaluate,g=d.interpolate,d=d.variable;return f==o&&(f=j.escape),e==o&&(e=j.evaluate),g==o&&(g=j.interpolate),f&&(a=a.replace(f,wa)),g&&(a=a.replace(g,xa)),e&&(a=a.replace(e,ya)),a="__p='"+a.replace(Ca,ua).replace(Ba,ta)+"';\n",w.length=0,d||(d=j.variable,a="with("+d+"||{}){"+a+"}"),a="function("+d+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}",j=Function("_","return "+ -a)(b),c?j(c):(j.source=a,j)},b.throttle=function(a,c){function b(){h=new Date,g=n,a.apply(e,j)}var j,f,e,g,h=0;return function(){var i=new Date,k=c-(i-h);return j=arguments,e=this,0>=k?(h=i,f=a.apply(e,j)):g||(g=P(b,k)),f}},b.times=function(a,c,b){b&&(c=v(c,b));for(b=0;bx(b,d[a])&& -b.push(d[a]);return b},b.uniq=ka,b.uniqueId=function(a){var b=za++;return a?a+b:b},b.values=qa,b.without=function(a){for(var b=l.call(arguments,1),d=-1,i=a.length,f=[];++dx(b,a[d])&&f.push(a[d]);return f},b.wrap=function(a,b){return function(){var d=[a];return arguments.length&&K.apply(d,arguments),b.apply(this,d)}},b.zip=function(){for(var a=-1,b=ia(Q(arguments,"length")),d=Array(b);++a/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"object"};var sa=Function("n","var __p;with(n){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" +),s={a:"f,d,x",k:"f",q:"if(!d){d=k}else if(x){d=c(d,x)}",j:"d(f[l],l,f)"},Y={k:"z",j:"if(!d(f[l],l,f))return!r"},Z={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ua?b():function(){if(1>--a)return b.apply(this,arguments)}},c.bind=u,c.bindAll=function(a){var b=arguments,d=1;1==b.length&&(d=0,b=O(a));for(var c=b.length;dx(e,a[b])&&c.push(a[b]);return c},c.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(f,b)&&$(e,function(a){return-1arguments.length&&(b=a||0,a=0);for(var c=-1,e=Math.max(Math.ceil((b-a)/d),0),f=Array(e);++cc?1:0}),"b")},c.sortedIndex=ha,c.tap=function(a,b){return b(a),a} +,c.template=function(a,b,d){d||(d={});var h;h=c.templateSettings;var e=d.escape,f=d.evaluate,g=d.interpolate,d=d.variable;return e==n&&(e=h.escape),f==n&&(f=h.evaluate),g==n&&(g=h.interpolate),e&&(a=a.replace(e,wa)),g&&(a=a.replace(g,xa)),f&&(a=a.replace(f,ya)),a="__p='"+a.replace(Ca,ua).replace(Ba,ta)+"';\n",v.length=0,d||(d=h.variable,a="with("+d+"||{}){"+a+"}"),a="function("+d+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}",h=Function("_","return "+ +a)(c),b?h(b):(h.source=a,h)},c.throttle=function(a,b){function d(){h=new Date,g=m,a.apply(f,c)}var c,e,f,g,h=0;return function(){var j=new Date,k=b-(j-h);return c=arguments,f=this,0>=k?(h=j,e=a.apply(f,c)):g||(g=P(d,k)),e}},c.times=function(a,b,d){d&&(b=u(b,d));for(d=0;dx(b,d[a])&& +b.push(d[a]);return b},c.uniq=ka,c.uniqueId=function(a){var b=za++;return a?a+b:b},c.values=qa,c.without=function(a){for(var b=k.call(arguments,1),d=-1,c=a.length,e=[];++dx(b,a[d])&&e.push(a[d]);return e},c.wrap=function(a,b){return function(){var d=[a];return arguments.length&&K.apply(d,arguments),b.apply(this,d)}},c.zip=function(){for(var a=-1,b=ia(Q(arguments,"length")),d=Array(b);++a Date: Sat, 26 May 2012 00:07:50 -0400 Subject: [PATCH 04/19] Tweak `_.find` to avoid using `_.identity` and add benchmark. Former-commit-id: a881f90d00828ed6af5b2b0bc80c9ae6e2cb2da8 --- lodash.js | 11 +++++++---- perf/perf.js | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lodash.js b/lodash.js index 42240a7dd0..c6ad50bca5 100644 --- a/lodash.js +++ b/lodash.js @@ -302,6 +302,11 @@ 'inLoop': 'callback(collection[index], index, collection) && result.push(collection[index])' }; + /** Reusable iterator options for `find` and `forEach` */ + var forEachIteratorOptions = { + 'top': 'if (thisArg) callback = bind(callback, thisArg)' + }; + /** Reusable iterator options for `map`, `pluck`, and `values` */ var mapIteratorOptions = { 'init': '', @@ -584,7 +589,7 @@ * var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); * // => 2 */ - var find = createIterator(baseIteratorOptions, { + var find = createIterator(baseIteratorOptions, forEachIteratorOptions, { 'init': '', 'inLoop': 'if (callback(collection[index], index, collection)) return collection[index]' }); @@ -611,9 +616,7 @@ * _([1, 2, 3]).forEach(function(num) { alert(num); }).join(','); * // => alerts each number in turn and returns '1,2,3' */ - var forEach = createIterator(baseIteratorOptions, { - 'top': 'if (thisArg) callback = bind(callback, thisArg)' - }); + var forEach = createIterator(baseIteratorOptions, forEachIteratorOptions); /** * Produces a new array of values by mapping each value in the `collection` diff --git a/perf/perf.js b/perf/perf.js index dd6c8f52a2..1bbba5dcb3 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -205,6 +205,22 @@ /*--------------------------------------------------------------------------*/ + suites.push( + Benchmark.Suite('find') + .add('Lo-Dash', function() { + lodash.find(numbers, function(num) { + return num === 19; + }); + }) + .add('Underscore', function() { + _.find(numbers, function(num) { + return num === 19; + }); + }) + ); + + /*--------------------------------------------------------------------------*/ + suites.push( Benchmark.Suite('flatten deep') .add('Lo-Dash', function() { From dde3eb2e36200b405537e1956a5c1a48ed5f5929 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 26 May 2012 00:09:11 -0400 Subject: [PATCH 05/19] Update `_.find` dependencies. Former-commit-id: 88e6c8dec2cf62d348bc570c0f3f9bfa23a9dc5c --- build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.js b/build.js index a2f37d863d..a4bea8a45d 100755 --- a/build.js +++ b/build.js @@ -75,7 +75,7 @@ 'every': ['bind', 'createIterator', 'identity'], 'extend': ['createIterator'], 'filter': ['bind', 'createIterator', 'identity'], - 'find': ['createIterator'], + 'find': ['bind', 'createIterator'], 'first': [], 'flatten': ['isArray'], 'forEach': ['bind', 'createIterator'], From 43ea0c9072175db6711209ab9208edfa81dbe65f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 26 May 2012 00:09:24 -0400 Subject: [PATCH 06/19] Reword unit test and add entry to README.md. Former-commit-id: e5d68317bb8f2688c256de096c58e1b49014a68c --- README.md | 2 ++ test/test.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ceba6f9e9..0b22084de4 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ git submodule update --init ## Closed Underscore.js issues + * Ensure `_(...)` returns passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L95-98)] * Ensure `_.groupBy` adds values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L229-236)] * Ensure `_.throttle` works when called in tight loops [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L436-446)] * Fix Firefox, IE, Opera, and Safari object iteration bugs [[#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L152-172), [test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L206-213), [test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L255-257), [test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L265-267), [test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L285-292), [test](https://github.com/bestiejs/lodash/blob/32627f45072952df18a64cf5e9f2433d2d32730f/test/test.js#L386-388)] @@ -203,6 +204,7 @@ git submodule update --init * Added whitespace to compiled strings * Added `_.partial` method * Commented the `iterationFactory` options object + * Ensured `_(...)` returns passed wrapper instances * Ensured `_.max` and `_.min` support extremely large arrays * Ensured `_.throttle` works in tight loops * Fixed IE < 9 `[DontEnum]` bug and Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1’s prototype property iteration bug diff --git a/test/test.js b/test/test.js index 9eb1b18441..da7263a8bc 100644 --- a/test/test.js +++ b/test/test.js @@ -92,7 +92,7 @@ ok(_() instanceof _); }); - test('should pass through LoDash instances', function() { + test('should return passed LoDash instances', function() { var wrapped = _([]); equal(_(wrapped), wrapped); }); From 74a2d8dcb1a0f3fcf31e8dc5ec77dc81276cf23d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 26 May 2012 00:12:43 -0400 Subject: [PATCH 07/19] Update Backbone and Underscore submodules. Former-commit-id: 13de1bae42bbbae7ca138bc5d26b83fd66367343 --- vendor/backbone | 2 +- vendor/underscore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/backbone b/vendor/backbone index 3c7c8d2f1a..5509e13842 160000 --- a/vendor/backbone +++ b/vendor/backbone @@ -1 +1 @@ -Subproject commit 3c7c8d2f1af5ded3067324579ca6ff0f5dcb2893 +Subproject commit 5509e13842a4d8e9c2c2fd59d86492bbf6c0b596 diff --git a/vendor/underscore b/vendor/underscore index 0da7b393b0..99d1023a8b 160000 --- a/vendor/underscore +++ b/vendor/underscore @@ -1 +1 @@ -Subproject commit 0da7b393b08c2459bc302f4ccb6401587b1fb1da +Subproject commit 99d1023a8b0912d15215d186f580dafc27f2d04a From e335e0fd72a393a2d3738ff88d068988940b31a2 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 26 May 2012 03:35:39 -0400 Subject: [PATCH 08/19] Add mobile build support. [closes #14] Former-commit-id: a73e3ea444f04027e28beeb9d007a19c169c4fa9 --- build.js | 97 +++++++++++++++++++++++++++++++------------- build/pre-compile.js | 1 + 2 files changed, 70 insertions(+), 28 deletions(-) diff --git a/build.js b/build.js index a4bea8a45d..cdbf920c6f 100755 --- a/build.js +++ b/build.js @@ -328,36 +328,18 @@ return removeFromCreateIterator(source, varName); } - /*--------------------------------------------------------------------------*/ - - // inline `iteratorTemplate` - (function() { - var iteratorTemplate = lodash._iteratorTemplate, - code = /^function[^{]+{([\s\S]+?)}$/.exec(iteratorTemplate)[1]; - - // remove whitespace from template - code = code.replace(/\[object |else if|function | in |return\s+[\w']|throw |typeof |var |\\\\n|\\n|\s+/g, function(match) { + /** + * Removes non-syntax critical whitespace from a string. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the source with whitespace removed. + */ + function removeWhitespace(source) { + return source.replace(/\[object |else if|function | in |return\s+[\w']|throw |typeof |var |\\\\n|\\n|\s+/g, function(match) { return match == false || match == '\\n' ? '' : match; }); - - // remove unnecessary code - code = code - .replace(/\|\|\{\}|,__t,__j=Array.prototype.join|function print[^}]+}|\+''/g, '') - .replace(/(\{);|;(\})/g, '$1$2') - .replace(/\(\(__t=\(([^)]+)\)\)==null\?'':__t\)/g, '$1'); - - // ensure escaped characters are interpreted correctly inside the `Function()` string - code = code.replace(/\\/g, '\\\\'); - - // add `code` to `Function()` - code = '$1Function(\'object\',\n$2 "' + code + '"\n$2);\n'; - - // replace `template()` with `Function()` - source = source.replace(/(( +)var iteratorTemplate *= *)([\s\S]+?\n\2.+?);\n/, code); - - // remove pseudo private property `_iteratorTemplate` - source = source.replace(/(?:\s*\/\/.*)*\s*lodash\._iteratorTemplate\b.+\n/, '\n'); - }()); + } /*--------------------------------------------------------------------------*/ @@ -436,6 +418,65 @@ return true; }); + /*--------------------------------------------------------------------------*/ + + (function() { + // for mobile builds + if (process.argv.indexOf('mobile') > -1) { + // set custom build flag + isCustom = true; + + // inline functions defined with `createIterator` + lodash.functions(lodash).forEach(function(funcName) { + var reFunc = RegExp('( +var ' + funcName + ' *= *)((?:[a-zA-Z]+ *\\|\\| *)?)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n'), + parts = source.match(reFunc); + + // skip if not defined with `createIterator` + if (!parts) { + return; + } + source = source.replace(reFunc, + (funcName == 'keys' + ? '$1$2' + lodash._createIterator(Function('return ' + parts[3])()) + : '$1' + lodash[funcName] + ) + ';\n' + ); + }); + + // remove `iteratorTemplate` + source = removeVar(source, 'iteratorTemplate'); + + // remove JScript [[DontEnum]] fix from `isEqual` + source = source.replace(/(?:\s*\/\/.*\n)*( +)if *\(result *&& *hasDontEnumBug[\s\S]+?\n\1}\n/, '\n'); + } + // for normal builds + else { + // extract `iteratorTemplate` source + var iteratorTemplateCode = /^function[^{]+{([\s\S]+?)}$/.exec(lodash._iteratorTemplate)[1]; + + // remove whitespace and unnecessary code + iteratorTemplateCode = removeWhitespace(iteratorTemplateCode) + .replace(/\|\|\{\}|,__t,__j=Array.prototype.join|function print[^}]+}|\+''/g, '') + .replace(/(\{);|;(\})/g, '$1$2') + .replace(/\(\(__t=\(([^)]+)\)\)==null\?'':__t\)/g, '$1'); + + // ensure escaped characters are interpreted correctly inside the `Function()` string + iteratorTemplateCode = iteratorTemplateCode.replace(/\\/g, '\\\\'); + + // add `iteratorTemplateCode` to `Function()` to avoid strict mode error + // for using a with-statement + iteratorTemplateCode = '$1Function(\'object\',\n$2 "' + iteratorTemplateCode + '"\n$2);\n'; + + // replace `template()` with `Function()` + source = source.replace(/(( +)var iteratorTemplate *= *)([\s\S]+?\n\2.+?);\n/, iteratorTemplateCode); + } + + // remove pseudo private properties + source = source.replace(/(?:\s*\/\/.*)*\s*lodash\._(?:createIterator|iteratorTemplate)\b.+\n/g, '\n'); + }()); + + /*--------------------------------------------------------------------------*/ + // begin the minification process if (isCustom) { fs.writeFileSync(path.join(__dirname, 'lodash.custom.js'), source); diff --git a/build/pre-compile.js b/build/pre-compile.js index 24781f09be..36e6ed9dab 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -65,6 +65,7 @@ /** Used protect the specified properties from getting minified */ var propWhitelist = [ '_', + '_chain', '_wrapped', 'after', 'all', From 570ba189ede87deaeaeb25439db098959c971138 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 26 May 2012 03:36:03 -0400 Subject: [PATCH 09/19] Update docs and minified build. Former-commit-id: d07b191ef424d6dce31e690e4af5293eb1525313 --- doc/README.md | 168 +++++++++++++++++++++++++------------------------- lodash.min.js | 52 ++++++++-------- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/doc/README.md b/doc/README.md index 021fe5a462..debd139821 100644 --- a/doc/README.md +++ b/doc/README.md @@ -145,7 +145,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3093 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -157,7 +157,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1619 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1622 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -185,7 +185,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1670 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1673 "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`. @@ -232,7 +232,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1741 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1744 "View in source") [Ⓣ][1] Binds methods on the `object` to the object, overwriting the non-bound method. If no method names are provided, all the function properties of the `object` will be bound. @@ -264,7 +264,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3042 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3045 "View in source") [Ⓣ][1] Wraps the value in a `lodash` chainable object. @@ -298,7 +298,7 @@ var youngest = _.chain(stooges) ### `_.clone(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2067 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2070 "View in source") [Ⓣ][1] Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned. @@ -322,7 +322,7 @@ _.clone({ 'name': 'moe' }); ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L880 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L883 "View in source") [Ⓣ][1] Produces a new array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -346,7 +346,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1773 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1776 "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 thefunctions `f()`, `g()`, and `h()` produces `f(g(h()))`. @@ -373,7 +373,7 @@ welcome('moe'); ### `_.contains(collection, target)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L520 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L525 "View in source") [Ⓣ][1] Checks if a given `target` value is present in a `collection` using strict equality for comparisons, i.e. `===`. @@ -398,7 +398,7 @@ _.contains([1, 2, 3], 3); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1809 "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. @@ -424,7 +424,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, defaults1, defaults2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2093 "View in source") [Ⓣ][1] Assigns missing properties in `object` with default values from the defaults objects. As soon as a property is set, additional defaults of the same property will be ignored. @@ -450,7 +450,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'lots' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1871 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1874 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments are passed to `func` when it is invoked. @@ -475,7 +475,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1851 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1854 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments are passed to `func` when it is invoked. @@ -502,7 +502,7 @@ _.delay(log, 1000, 'logged later'); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L909 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L912 "View in source") [Ⓣ][1] Produces a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -527,7 +527,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2741 "View in source") [Ⓣ][1] Escapes a string for insertion into HTML, replacing `&`, `<`, `"`, `'`, and `/` characters. @@ -551,7 +551,7 @@ _.escape('Curly, Larry & Moe'); ### `_.every(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L549 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -577,7 +577,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2109 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2112 "View in source") [Ⓣ][1] Copies enumerable properties from the source objects to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -602,7 +602,7 @@ _.extend({ 'name': 'moe' }, { 'age': 40 }); ### `_.filter(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L565 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L570 "View in source") [Ⓣ][1] Examines each value in a `collection`, returning an array of all values the `callback` returns truthy for. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -628,7 +628,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#L587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L592 "View in source") [Ⓣ][1] Examines each value in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable value, and does not iterate over the entire `collection`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -654,7 +654,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#L942 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L945 "View in source") [Ⓣ][1] Gets the first value of the `array`. Pass `n` to return the first `n` values of the `array`. @@ -680,7 +680,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L967 "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. @@ -708,7 +708,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.forEach(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L614 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L619 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each value in the `collection`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -737,7 +737,7 @@ _([1, 2, 3]).forEach(function(num) { alert(num); }).join(','); ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2126 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2129 "View in source") [Ⓣ][1] Produces a sorted array of the properties, own and inherited, of `object` that have function values. @@ -761,7 +761,7 @@ _.functions(_); ### `_.groupBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1006 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1009 "View in source") [Ⓣ][1] Splits a `collection` into sets, grouped by the result of running each value through `callback`. The `callback` is invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to group by. @@ -793,7 +793,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2152 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -818,7 +818,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2765 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -843,7 +843,7 @@ moe === _.identity(moe); ### `_.indexOf(array, value [, isSorted=false])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1091 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1094 "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. @@ -869,7 +869,7 @@ _.indexOf([1, 2, 3], 2); ### `_.initial(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1125 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1128 "View in source") [Ⓣ][1] Gets all but the last value of the `array`. Pass `n` to exclude the last `n` values from the result. @@ -895,7 +895,7 @@ _.initial([5, 4, 3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1143 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1146 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays. @@ -919,7 +919,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.invoke(array, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1176 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1179 "View in source") [Ⓣ][1] Calls the method named by `methodName` for each value of the `collection`. Additional arguments will be passed to each invoked method. @@ -945,7 +945,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2169 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2172 "View in source") [Ⓣ][1] Checks if a `value` is an `arguments` object. @@ -972,7 +972,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2195 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2198 "View in source") [Ⓣ][1] Checks if a `value` is an array. @@ -999,7 +999,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2212 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2215 "View in source") [Ⓣ][1] Checks if a `value` is a boolean *(`true` or `false`)* value. @@ -1023,7 +1023,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2229 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2232 "View in source") [Ⓣ][1] Checks if a `value` is a date. @@ -1047,7 +1047,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2246 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2249 "View in source") [Ⓣ][1] Checks if a `value` is a DOM element. @@ -1071,7 +1071,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2267 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2270 "View in source") [Ⓣ][1] Checks if a `value` is empty. Arrays or strings with a length of `0` and objects with no enumerable own properties are considered "empty". @@ -1098,7 +1098,7 @@ _.isEmpty({}); ### `_.isEqual(a, b [, stack])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2301 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2304 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -1130,7 +1130,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2453 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2456 "View in source") [Ⓣ][1] Checks if a `value` is a finite number. @@ -1160,7 +1160,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2473 "View in source") [Ⓣ][1] Checks if a `value` is a function. @@ -1184,7 +1184,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2521 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2524 "View in source") [Ⓣ][1] Checks if a `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. @@ -1217,7 +1217,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2543 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] Checks if a `value` is `null`. @@ -1244,7 +1244,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2560 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2563 "View in source") [Ⓣ][1] Checks if a `value` is a number. @@ -1268,7 +1268,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2491 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2494 "View in source") [Ⓣ][1] Checks if a `value` is the language type of Object. *(e.g. arrays, functions, objects, regexps, `new Number(0)*`, and `new String('')`) @@ -1295,7 +1295,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2577 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2580 "View in source") [Ⓣ][1] Checks if a `value` is a regular expression. @@ -1319,7 +1319,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2594 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2597 "View in source") [Ⓣ][1] Checks if a `value` is a string. @@ -1343,7 +1343,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2611 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2614 "View in source") [Ⓣ][1] Checks if a `value` is `undefined`. @@ -1367,7 +1367,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2631 "View in source") [Ⓣ][1] Produces an array of the `object`'s enumerable own property names. @@ -1391,7 +1391,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.last(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1206 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1209 "View in source") [Ⓣ][1] Gets the last value of the `array`. Pass `n` to return the lasy `n` values of the `array`. @@ -1417,7 +1417,7 @@ _.last([5, 4, 3, 2, 1]); ### `_.lastIndexOf(array, value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1226 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1229 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. @@ -1442,7 +1442,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); ### `_.map(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L640 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L643 "View in source") [Ⓣ][1] Produces a new array of values by mapping each value in the `collection` through a transformation `callback`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1471,7 +1471,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#L1263 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "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 invoked with `3` arguments; *(value, index, array)*. @@ -1503,7 +1503,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1894 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1897 "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. @@ -1529,7 +1529,7 @@ var fibonacci = _.memoize(function(n) { ### `_.min(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1312 "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 invoked with `3` arguments; *(value, index, array)*. @@ -1555,7 +1555,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2791 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1585,7 +1585,7 @@ _('larry').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2822 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2825 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1605,7 +1605,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1920 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1923 "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. @@ -1631,7 +1631,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1953 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1956 "View in source") [Ⓣ][1] Creates a new function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the partially applied function. This method is similar `bind`, except it does **not** alter the `this` binding. @@ -1658,7 +1658,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2650 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] Creates an object composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. @@ -1683,7 +1683,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L662 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L665 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all values in a `collection`. @@ -1714,7 +1714,7 @@ _.pluck(stooges, 'name'); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1369 "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. @@ -1752,7 +1752,7 @@ _.range(0); ### `_.reduce(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L692 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L695 "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 the `thisArg` value, if one is passed. The `callback` is invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*. @@ -1779,7 +1779,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#L732 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L735 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*. @@ -1807,7 +1807,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L785 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L788 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1833,7 +1833,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#L1402 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1405 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of the `array`. Pass `n` to exclude the first `n` values from the result. @@ -1859,7 +1859,7 @@ _.rest([5, 4, 3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2852 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2855 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If the property is a function it will be invoked and its result returned, else the property value is returned. @@ -1894,7 +1894,7 @@ _.result(object, 'stuff'); ### `_.shuffle(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1423 "View in source") [Ⓣ][1] Produces a new array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1918,7 +1918,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2692 "View in source") [Ⓣ][1] Gets the size of a `value` by returning `value.length` if `value` is a string or array, or the number of own enumerable properties if `value` is an object. @@ -1948,7 +1948,7 @@ _.size('curly'); ### `_.some(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L809 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L812 "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 invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1974,7 +1974,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1048 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1051 "View in source") [Ⓣ][1] Produces a new sorted array, ranked in ascending order by the results of running each value of a `collection` through `callback`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -2003,7 +2003,7 @@ _.sortBy([1, 2, 3, 4, 5, 6], function(num) { return this.sin(num); }, Math); ### `_.sortedIndex(array, value [, callback])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1454 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1457 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into the `collection` in order to maintain the sort order of the `collection`. If `callback` is passed, it will be executed for each value in the `collection` to compute their sort ranking. The `callback` is invoked with `1` argument; *(value)*. @@ -2029,7 +2029,7 @@ _.sortedIndex([10, 20, 30, 40, 50], 35); ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2720 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The primary purpose of this method is to "tap into" a method chain, in order to performoperations on intermediate results within the chain. @@ -2059,7 +2059,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2912 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2915 "View in source") [Ⓣ][1] A JavaScript micro-templating method, similar to John Resig's implementation. Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2119,7 +2119,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' }); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1989 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1992 "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, `func` will also be called on the trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2144,7 +2144,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2989 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2992 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is invoked with `1` argument; *(index)*. @@ -2166,7 +2166,7 @@ _.times(3, function() { genie.grantWish(); }); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L828 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L831 "View in source") [Ⓣ][1] Converts the `collection`, into an array. Useful for converting the `arguments` object. @@ -2190,7 +2190,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1487 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1490 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays. @@ -2214,7 +2214,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1522 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1525 "View in source") [Ⓣ][1] Produces 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 value of `array` is passed through a transformation `callback` before uniqueness is computed. The `callback` is invoked with `3` arguments; *(value, index, array)*. @@ -2240,7 +2240,7 @@ _.uniq([1, 2, 1, 3, 1, 4]); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3012 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3015 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2264,7 +2264,7 @@ _.uniqueId('contact_'); ### `_.values(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L859 "View in source") [Ⓣ][1] Produces an array of enumerable own property values of the `collection`. @@ -2288,7 +2288,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1557 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1560 "View in source") [Ⓣ][1] Produces a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2313,7 +2313,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(func, wrapper [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2041 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2044 "View in source") [Ⓣ][1] Create a new function that passes the `func` function to the `wrapper` function as its first argument. Additional arguments are appended to those passed to the `wrapper` function. @@ -2343,7 +2343,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1590 "View in source") [Ⓣ][1] Merges together the values of each of the arrays with the value at the corresponding position. 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. @@ -2374,7 +2374,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3063 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2395,7 +2395,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3077 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3080 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. diff --git a/lodash.min.js b/lodash.min.js index bd3ba9bd41..0ca945c4ed 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -2,29 +2,29 @@ Lo-Dash 0.2.1 lodash.com/license Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE */ -;(function(t,m){"use strict";function R(a){return"[object Arguments]"==h.call(a)}function c(a){return new o(a)}function o(a){if(a&&a._wrapped)return a;this._wrapped=a}function j(){for(var a,b,d,w=-1,c=arguments.length,f={e:"",f:"",k:"",q:"",c:{d:"",m:"++l/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"object"};var sa=Function("n","var __p;with(n){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" -),s={a:"f,d,x",k:"f",q:"if(!d){d=k}else if(x){d=c(d,x)}",j:"d(f[l],l,f)"},Y={k:"z",j:"if(!d(f[l],l,f))return!r"},Z={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ua?b():function(){if(1>--a)return b.apply(this,arguments)}},c.bind=u,c.bindAll=function(a){var b=arguments,d=1;1==b.length&&(d=0,b=O(a));for(var c=b.length;dx(e,a[b])&&c.push(a[b]);return c},c.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(f,b)&&$(e,function(a){return-1arguments.length&&(b=a||0,a=0);for(var c=-1,e=Math.max(Math.ceil((b-a)/d),0),f=Array(e);++cc?1:0}),"b")},c.sortedIndex=ha,c.tap=function(a,b){return b(a),a} -,c.template=function(a,b,d){d||(d={});var h;h=c.templateSettings;var e=d.escape,f=d.evaluate,g=d.interpolate,d=d.variable;return e==n&&(e=h.escape),f==n&&(f=h.evaluate),g==n&&(g=h.interpolate),e&&(a=a.replace(e,wa)),g&&(a=a.replace(g,xa)),f&&(a=a.replace(f,ya)),a="__p='"+a.replace(Ca,ua).replace(Ba,ta)+"';\n",v.length=0,d||(d=h.variable,a="with("+d+"||{}){"+a+"}"),a="function("+d+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}",h=Function("_","return "+ -a)(c),b?h(b):(h.source=a,h)},c.throttle=function(a,b){function d(){h=new Date,g=m,a.apply(f,c)}var c,e,f,g,h=0;return function(){var j=new Date,k=b-(j-h);return c=arguments,f=this,0>=k?(h=j,e=a.apply(f,c)):g||(g=P(d,k)),e}},c.times=function(a,b,d){d&&(b=u(b,d));for(d=0;dx(b,d[a])&& -b.push(d[a]);return b},c.uniq=ka,c.uniqueId=function(a){var b=za++;return a?a+b:b},c.values=qa,c.without=function(a){for(var b=k.call(arguments,1),d=-1,c=a.length,e=[];++dx(b,a[d])&&e.push(a[d]);return e},c.wrap=function(a,b){return function(){var d=[a];return arguments.length&&K.apply(d,arguments),b.apply(this,d)}},c.zip=function(){for(var a=-1,b=ia(Q(arguments,"length")),d=Array(b);++a/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"object"};var sa=Function("n","var __p;with(n){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" +),t={a:"f,d,x",k:"f",q:"if(!d){d=k}else if(x){d=c(d,x)}",j:"d(f[l],l,f)"},Z={k:"z",j:"if(!d(f[l],l,f))return!r"},$={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ua?c():function(){if(1>--a)return c.apply(this,arguments)}},b.bind=v,b.bindAll=function(a){var c=arguments,d=1;1==c.length&&(d=0,c=P(a));for(var b=c.length;dx(f,a[c])&&b.push(a[c]);return b},b.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(e,c)&&aa(f,function(a){return-1arguments.length&&(c=a||0,a=0);for(var b=-1,f=Math.max(Math.ceil((c-a)/d),0),e=Array(f);++bd?1:0}),"b")},b.sortedIndex=ha,b.tap=function( +a,c){return c(a),a},b.template=function(a,c,d){d||(d={});var j;j=b.templateSettings;var f=d.escape,e=d.evaluate,g=d.interpolate,d=d.variable;return f==o&&(f=j.escape),e==o&&(e=j.evaluate),g==o&&(g=j.interpolate),f&&(a=a.replace(f,wa)),g&&(a=a.replace(g,xa)),e&&(a=a.replace(e,ya)),a="__p='"+a.replace(Ca,ua).replace(Ba,ta)+"';\n",w.length=0,d||(d=j.variable,a="with("+d+"||{}){"+a+"}"),a="function("+d+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}" +,j=Function("_","return "+a)(b),c?j(c):(j.source=a,j)},b.throttle=function(a,c){function b(){h=new Date,g=n,a.apply(e,j)}var j,f,e,g,h=0;return function(){var i=new Date,k=c-(i-h);return j=arguments,e=this,0>=k?(h=i,f=a.apply(e,j)):g||(g=Q(b,k)),f}},b.times=function(a,c,b){b&&(c=v(c,b));for(b=0;bx(b,d[a])&&b.push(d[a]);return b},b.uniq=ka,b.uniqueId=function(a){var b=za++;return a?a+b:b},b.values=qa,b.without=function(a){for(var b=l.call(arguments,1),d=-1,i=a.length,f=[];++dx(b,a[d])&&f.push(a[d]);return f},b.wrap=function(a,b){return function(){var d=[a];return arguments.length&&L.apply(d,arguments),b.apply(this,d)}},b.zip=function(){for(var a=-1,b=ia(R(arguments,"length")),d=Array(b);++a Date: Tue, 29 May 2012 14:40:03 +0300 Subject: [PATCH 10/19] Fix typo in build script Former-commit-id: 1f5327ea167ba88c00c6fcff5bbad3d64be6049b --- build/pre-compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 36e6ed9dab..7270bebc06 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -62,7 +62,7 @@ /** Used to minify variables and string values to a single character */ var minNames = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); - /** Used protect the specified properties from getting minified */ + /** Used to protect the specified properties from getting minified */ var propWhitelist = [ '_', '_chain', From c1860d30d648217b036c0e963d3442682077c094 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 29 May 2012 15:49:11 +0200 Subject: [PATCH 11/19] Optimize `escape()` by not needlessly escaping the `/` character Ref. #18. Former-commit-id: 82a29019daa15c83cb2159685ca5d575265cd902 --- lodash.js | 3 +-- lodash.min.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index c6ad50bca5..405c71b8db 100644 --- a/lodash.js +++ b/lodash.js @@ -2746,8 +2746,7 @@ .replace(/&/g, '&') .replace(/a?c():function(){if(1>--a)return c.apply(this,arguments)}},b.bind=v,b.bindAll=function(a){var c=arguments,d=1;1==c.length&&(d=0,c=P(a));for(var b=c.length;dx(f,a[c])&&b.push(a[c]);return b},b.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(f,a[c])&&b.push(a[c]);return b},b.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(e,c)&&aa(f,function(a){return-1 Date: Tue, 29 May 2012 10:14:40 -0400 Subject: [PATCH 12/19] Change the default value of `_.templateSettings.variable` to `obj` for Underscore.js compatibility. [closes #16] Former-commit-id: da91e5c881e6b3f9e2108cc231e57c023884b251 --- lodash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index c6ad50bca5..c3cb7540b5 100644 --- a/lodash.js +++ b/lodash.js @@ -176,7 +176,7 @@ * @memberOf _.templateSettings * @type String */ - 'variable': 'object' + 'variable': 'obj' }; /*--------------------------------------------------------------------------*/ From 8ef039b9dbff905431c9428cb3729e05f29ce2a7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 29 May 2012 10:17:55 -0400 Subject: [PATCH 13/19] Update unit test with `_.templateSettings.variable` change. Former-commit-id: e29718c70b0b0bcfeaf54909a32366d12663984d --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index da7263a8bc..e98c8ab091 100644 --- a/test/test.js +++ b/test/test.js @@ -402,7 +402,7 @@ (function() { test('supports recursive calls', function() { - var compiled = _.template('<%= a %><% a = _.template(c, object) %><%= a %>'), + var compiled = _.template('<%= a %><% a = _.template(c, obj) %><%= a %>'), data = { 'a': 'A', 'b': 'B', 'c': '<%= b %>' }; equal(compiled(data), 'AB'); From 205ded45e276531fc7910c05c4bcf1e62f64531a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 29 May 2012 10:18:32 -0400 Subject: [PATCH 14/19] Update submodules, minified build, and documentation. Former-commit-id: 526a3d4e7b68da2072163a656566ff777b591b2d --- doc/README.md | 22 +++++++++++----------- lodash.min.js | 26 +++++++++++++------------- vendor/underscore | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/README.md b/doc/README.md index debd139821..b7e324c35b 100644 --- a/doc/README.md +++ b/doc/README.md @@ -145,7 +145,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3093 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3092 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -264,7 +264,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3045 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3044 "View in source") [Ⓣ][1] Wraps the value in a `lodash` chainable object. @@ -818,7 +818,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2767 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -1555,7 +1555,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2793 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1585,7 +1585,7 @@ _('larry').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2825 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2824 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1859,7 +1859,7 @@ _.rest([5, 4, 3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2855 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2854 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If the property is a function it will be invoked and its result returned, else the property value is returned. @@ -2059,7 +2059,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2915 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2914 "View in source") [Ⓣ][1] A JavaScript micro-templating method, similar to John Resig's implementation. Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2144,7 +2144,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2992 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2991 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is invoked with `1` argument; *(index)*. @@ -2240,7 +2240,7 @@ _.uniq([1, 2, 1, 3, 1, 4]); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3015 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3014 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2374,7 +2374,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3063 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3062 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2395,7 +2395,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3079 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. diff --git a/lodash.min.js b/lodash.min.js index 3da76c788c..e588a070a5 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -11,20 +11,20 @@ g.push(a[f]);return g}function v(a,c){function d(){var g=arguments,h=c;return f| )for(;g--&&(e=N(a[g],c[g],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return q;for(var h in a)if(s.call(a,h)&&(g++,!(e=s.call(c,h)&&N(a[h],c[h],d))))break;if(e){for(h in c)if(s.call(c,h)&&!(g--))break;e=!g}if(e&&H)for(;7>++f&&(h=ca[f],!s.call(a,h)||!!(e=s.call(c,h)&&N(a[h],c[h],d))););}return d.pop(),e}function da(a){return a}function oa(a){C(P(a),function(c){var d=b[c]=a[c];p.prototype[c]=function(){var a=[this._wrapped];return arguments.length&&L.apply(a,arguments ),a=1==a.length?d.call(b,a[0]):d.apply(b,a),this._chain&&(a=new p(a),a._chain=m),a}})}var m=!0,o=null,q=!1,X="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(u=global),exports),va={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},H=!{valueOf:0}.propertyIsEnumerable("valueOf"),za=0,J={"boolean":q,"function":m,object:m,number:q,string:q,"undefined":q},Aa=u._,z=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&" ).replace(/valueOf|for [^\]]+/g,".+?")+"$"),Ba=/__token__(\d+)/g,Ca=/['\n\r\t\u2028\u2029\\]/g,ca="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),T="__token__",w=[],I="[object Array]",la="[object Boolean]",ma="[object Date]",r="[object Function]",O="[object Number]",na="[object RegExp]",K="[object String]",A=Array.prototype,D=Object.prototype,M=A.concat,s=D.hasOwnProperty,L=A.push,l=A.slice,i=D.toString,y=z.test(y=l.bind)&&/\n|Opera/.test -(y+i.call(u.opera))&&y,E=z.test(E=Array.isArray)&&E,Da=u.isFinite,Y=z.test(Y=Object.keys)&&Y,Ea=u.clearTimeout,Q=u.setTimeout;b.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"object"};var sa=Function("n","var __p;with(n){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" +(y+i.call(u.opera))&&y,E=z.test(E=Array.isArray)&&E,Da=u.isFinite,Y=z.test(Y=Object.keys)&&Y,Ea=u.clearTimeout,Q=u.setTimeout;b.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var sa=Function("n","var __p;with(obj){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" ),t={a:"f,d,x",k:"f",q:"if(!d){d=k}else if(x){d=c(d,x)}",j:"d(f[l],l,f)"},Z={k:"z",j:"if(!d(f[l],l,f))return!r"},$={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ua?c():function(){if(1>--a)return c.apply(this,arguments)}},b.bind=v,b.bindAll=function(a){var c=arguments,d=1;1==c.length&&(d=0,c=P(a));for(var b=c.length;dx(f,a[c])&&b.push(a[c]);return b},b.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(e,c)&&aa(f,function(a){return-1arguments.length&&(c=a||0,a=0);for(var b=-1,f=Math.max(Math.ceil((c-a)/d),0),e=Array(f);++bd?1:0}),"b")},b.sortedIndex=ha,b.tap=function( -a,c){return c(a),a},b.template=function(a,c,d){d||(d={});var j;j=b.templateSettings;var f=d.escape,e=d.evaluate,g=d.interpolate,d=d.variable;return f==o&&(f=j.escape),e==o&&(e=j.evaluate),g==o&&(g=j.interpolate),f&&(a=a.replace(f,wa)),g&&(a=a.replace(g,xa)),e&&(a=a.replace(e,ya)),a="__p='"+a.replace(Ca,ua).replace(Ba,ta)+"';\n",w.length=0,d||(d=j.variable,a="with("+d+"||{}){"+a+"}"),a="function("+d+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}" -,j=Function("_","return "+a)(b),c?j(c):(j.source=a,j)},b.throttle=function(a,c){function b(){h=new Date,g=n,a.apply(e,j)}var j,f,e,g,h=0;return function(){var i=new Date,k=c-(i-h);return j=arguments,e=this,0>=k?(h=i,f=a.apply(e,j)):g||(g=Q(b,k)),f}},b.times=function(a,c,b){b&&(c=v(c,b));for(b=0;bx(b,d[a])&&b.push(d[a]);return b},b.uniq=ka,b.uniqueId=function(a){var b=za++;return a?a+b:b},b.values=qa,b.without=function(a){for(var b=l.call(arguments,1),d=-1,i=a.length,f=[];++dx(b,a[d])&&f.push(a[d]);return f},b.wrap=function(a,b){return function(){var d=[a];return arguments.length&&L.apply(d,arguments),b.apply(this,d)}},b.zip=function(){for(var a=-1,b=ia(R(arguments,"length")),d=Array(b);++ax(f,a[c])&&b.push(a[c]);return b},b.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(e,c)&&aa(f,function(a){return-1arguments.length&&(c=a||0,a=0);for(var b=-1,f=Math.max(Math.ceil((c-a)/d),0),e=Array(f);++bd?1:0}),"b")},b.sortedIndex=ha,b.tap=function(a,c){return c(a),a}, +b.template=function(a,c,d){d||(d={});var j;j=b.templateSettings;var f=d.escape,e=d.evaluate,g=d.interpolate,d=d.variable;return f==o&&(f=j.escape),e==o&&(e=j.evaluate),g==o&&(g=j.interpolate),f&&(a=a.replace(f,wa)),g&&(a=a.replace(g,xa)),e&&(a=a.replace(e,ya)),a="__p='"+a.replace(Ca,ua).replace(Ba,ta)+"';\n",w.length=0,d||(d=j.variable,a="with("+d+"||{}){"+a+"}"),a="function("+d+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}",j=Function("_","return "+ +a)(b),c?j(c):(j.source=a,j)},b.throttle=function(a,c){function b(){h=new Date,g=n,a.apply(e,j)}var j,f,e,g,h=0;return function(){var i=new Date,k=c-(i-h);return j=arguments,e=this,0>=k?(h=i,f=a.apply(e,j)):g||(g=Q(b,k)),f}},b.times=function(a,c,b){b&&(c=v(c,b));for(b=0;bx(b,d[a])&& +b.push(d[a]);return b},b.uniq=ka,b.uniqueId=function(a){var b=za++;return a?a+b:b},b.values=qa,b.without=function(a){for(var b=l.call(arguments,1),d=-1,i=a.length,f=[];++dx(b,a[d])&&f.push(a[d]);return f},b.wrap=function(a,b){return function(){var d=[a];return arguments.length&&L.apply(d,arguments),b.apply(this,d)}},b.zip=function(){for(var a=-1,b=ia(R(arguments,"length")),d=Array(b);++a Date: Tue, 29 May 2012 15:52:02 -0400 Subject: [PATCH 15/19] Cleanup build.js and fix regression in minified build. [closes #19] Former-commit-id: 3b455cb277fa8c3fc70efca7b54c6746cde2ea6b --- build.js | 157 ++++++++++++++++++++++++++++---------------------- lodash.min.js | 2 +- 2 files changed, 88 insertions(+), 71 deletions(-) diff --git a/build.js b/build.js index cdbf920c6f..9b5570f810 100755 --- a/build.js +++ b/build.js @@ -10,9 +10,6 @@ var lodash = require(path.join(__dirname, 'lodash')), minify = require(path.join(__dirname, 'build', 'minify')); - /** Flag used to specify a custom build */ - var isCustom = false; - /** Shortcut used to convert array-like objects to arrays */ var slice = [].slice; @@ -141,6 +138,23 @@ 'zip': ['max', 'pluck'] }; + /** Names of methods to filter for the build */ + var filterMethods = Object.keys(dependencyMap); + + /** Used to specify if `filterMethods` should be used for exclusion or inclusion */ + var filterType = process.argv.reduce(function(result, value) { + if (!result) { + var pair = value.match(/^(exclude|include)=(.*)$/); + if (pair) { + filterMethods = lodash.intersection(filterMethods, pair[2].split(/, */).map(getRealName)); + return pair[1]; + } + } + }, ''); + + /** Flag used to specify a mobile build */ + var isMobile = process.argv.indexOf('mobile') > -1; + /*--------------------------------------------------------------------------*/ /** @@ -344,22 +358,14 @@ /*--------------------------------------------------------------------------*/ // custom build - process.argv.some(function(arg) { - // exit early if not the "exclude" or "include" command option - var pair = arg.match(/^(exclude|include)=(.*)$/); - if (!pair) { - return false; + (function() { + // exit early if "exclude" or "include" options aren't specified + if (!filterType) { + return; } - - var filterType = pair[1], - filterNames = lodash.intersection(Object.keys(dependencyMap), pair[2].split(/, */).map(getRealName)); - - // set custom build flag - isCustom = true; - // remove the specified functions and their dependants if (filterType == 'exclude') { - filterNames.forEach(function(funcName) { + filterMethods.forEach(function(funcName) { getDependants(funcName).concat(funcName).forEach(function(otherName) { source = removeFunction(source, otherName); }); @@ -367,13 +373,13 @@ } // else remove all but the specified functions and their dependencies else { - filterNames = lodash.uniq(filterNames.reduce(function(result, funcName) { + filterMethods = lodash.uniq(filterMethods.reduce(function(result, funcName) { result.push.apply(result, getDependencies(funcName).concat(funcName)); return result; }, [])); lodash.each(dependencyMap, function(dependencies, otherName) { - if (filterNames.indexOf(otherName) < 0) { + if (filterMethods.indexOf(otherName) < 0) { source = removeFunction(source, otherName); } }); @@ -402,10 +408,22 @@ if (isRemoved(source, 'bind', 'functions', 'groupBy', 'invoke', 'isEqual', 'isFunction', 'result', 'sortBy', 'toArray')) { source = removeVar(source, 'funcClass'); } + if (isRemoved(source, 'bind')) { + source = removeVar(source, 'nativeBind'); + } + if (isRemoved(source, 'isArray')) { + source = removeVar(source, 'nativeIsArray'); + } + if (isRemoved(source, 'keys')) { + source = removeVar(source, 'nativeKeys'); + } if (isRemoved(source, 'clone', 'isObject', 'keys')) { source = removeVar(source, 'objectTypes'); source = removeFromCreateIterator(source, 'objectTypes'); } + if (isRemoved(source, 'bind', 'isArray', 'keys')) { + source = removeVar(source, 'reNative'); + } if (isRemoved(source, 'isEmpty', 'isEqual', 'isString', 'size')) { source = removeVar(source, 'stringClass'); } @@ -414,71 +432,70 @@ source = source.replace(/(?:\s*\/\*-+\*\/\s*){2,}/g, function(separators) { return separators.match(/^\s*/)[0] + separators.slice(separators.lastIndexOf('/*')); }); - - return true; - }); + }()); /*--------------------------------------------------------------------------*/ - (function() { - // for mobile builds - if (process.argv.indexOf('mobile') > -1) { - // set custom build flag - isCustom = true; - - // inline functions defined with `createIterator` - lodash.functions(lodash).forEach(function(funcName) { - var reFunc = RegExp('( +var ' + funcName + ' *= *)((?:[a-zA-Z]+ *\\|\\| *)?)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n'), - parts = source.match(reFunc); - - // skip if not defined with `createIterator` - if (!parts) { - return; - } - source = source.replace(reFunc, - (funcName == 'keys' - ? '$1$2' + lodash._createIterator(Function('return ' + parts[3])()) - : '$1' + lodash[funcName] - ) + ';\n' - ); - }); + if (isMobile) { + // inline functions defined with `createIterator` + lodash.functions(lodash).forEach(function(funcName) { + var reFunc = RegExp('( +var ' + funcName + ' *= *)((?:[a-zA-Z]+ *\\|\\| *)?)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n'), + parts = source.match(reFunc); - // remove `iteratorTemplate` - source = removeVar(source, 'iteratorTemplate'); - - // remove JScript [[DontEnum]] fix from `isEqual` - source = source.replace(/(?:\s*\/\/.*\n)*( +)if *\(result *&& *hasDontEnumBug[\s\S]+?\n\1}\n/, '\n'); - } - // for normal builds - else { - // extract `iteratorTemplate` source - var iteratorTemplateCode = /^function[^{]+{([\s\S]+?)}$/.exec(lodash._iteratorTemplate)[1]; + // skip if not defined with `createIterator` + if (!parts) { + return; + } + // extract function's code + var code = funcName == 'keys' + ? '$1$2' + lodash._createIterator(Function('return ' + parts[3])()) + : '$1' + lodash[funcName]; + + // format code + code = code.replace(/\n(?:.*)/g, function(match) { + match = match.slice(1); + return (match == '}' ? '\n ' : '\n ') + match; + }) + ';\n'; + + source = source.replace(reFunc, code); + }); - // remove whitespace and unnecessary code - iteratorTemplateCode = removeWhitespace(iteratorTemplateCode) - .replace(/\|\|\{\}|,__t,__j=Array.prototype.join|function print[^}]+}|\+''/g, '') - .replace(/(\{);|;(\})/g, '$1$2') - .replace(/\(\(__t=\(([^)]+)\)\)==null\?'':__t\)/g, '$1'); + // remove `iteratorTemplate` + source = removeVar(source, 'iteratorTemplate'); - // ensure escaped characters are interpreted correctly inside the `Function()` string - iteratorTemplateCode = iteratorTemplateCode.replace(/\\/g, '\\\\'); + // remove JScript [[DontEnum]] fix from `isEqual` + source = source.replace(/(?:\s*\/\/.*\n)*( +)if *\(result *&& *hasDontEnumBug[\s\S]+?\n\1}\n/, '\n'); - // add `iteratorTemplateCode` to `Function()` to avoid strict mode error - // for using a with-statement - iteratorTemplateCode = '$1Function(\'object\',\n$2 "' + iteratorTemplateCode + '"\n$2);\n'; + // remove IE `shift` and `splice` fix + source = source.replace(/(?:\s*\/\/.*\n)*( +)if *\(value.length *=== *0[\s\S]+?\n\1}\n/, '\n'); + } + else { + // inline `iteratorTemplate` template + source = source.replace(/(( +)var iteratorTemplate *= *)([\s\S]+?\n\2.+?);\n/, (function() { + // extract `iteratorTemplate` code + var code = /^function[^{]+{([\s\S]+?)}$/.exec(lodash._iteratorTemplate)[1]; - // replace `template()` with `Function()` - source = source.replace(/(( +)var iteratorTemplate *= *)([\s\S]+?\n\2.+?);\n/, iteratorTemplateCode); - } + code = removeWhitespace(code) + // remove unnecessary code + .replace(/\|\|\{\}|,__t,__j=Array.prototype.join|function print[^}]+}|\+''/g, '') + .replace(/(\{);|;(\})/g, '$1$2') + .replace(/\(\(__t=\(([^)]+)\)\)==null\?'':__t\)/g, '$1') + // ensure escaped characters are interpreted correctly in the string literal + .replace(/\\/g, '\\\\'); + + // add `code` to `Function()` as a string literal to avoid strict mode + // errors caused by the required with-statement + return '$1Function(\'obj\',\n$2 "' + code + '"\n$2);\n'; + }())); + } - // remove pseudo private properties - source = source.replace(/(?:\s*\/\/.*)*\s*lodash\._(?:createIterator|iteratorTemplate)\b.+\n/g, '\n'); - }()); + // remove pseudo private properties + source = source.replace(/(?:\s*\/\/.*)*\s*lodash\._(?:createIterator|iteratorTemplate)\b.+\n/g, '\n'); /*--------------------------------------------------------------------------*/ // begin the minification process - if (isCustom) { + if (filterType || isMobile) { fs.writeFileSync(path.join(__dirname, 'lodash.custom.js'), source); minify(source, 'lodash.custom.min', function(result) { fs.writeFileSync(path.join(__dirname, 'lodash.custom.min.js'), result); diff --git a/lodash.min.js b/lodash.min.js index e588a070a5..4bdb768c88 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -11,7 +11,7 @@ g.push(a[f]);return g}function v(a,c){function d(){var g=arguments,h=c;return f| )for(;g--&&(e=N(a[g],c[g],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return q;for(var h in a)if(s.call(a,h)&&(g++,!(e=s.call(c,h)&&N(a[h],c[h],d))))break;if(e){for(h in c)if(s.call(c,h)&&!(g--))break;e=!g}if(e&&H)for(;7>++f&&(h=ca[f],!s.call(a,h)||!!(e=s.call(c,h)&&N(a[h],c[h],d))););}return d.pop(),e}function da(a){return a}function oa(a){C(P(a),function(c){var d=b[c]=a[c];p.prototype[c]=function(){var a=[this._wrapped];return arguments.length&&L.apply(a,arguments ),a=1==a.length?d.call(b,a[0]):d.apply(b,a),this._chain&&(a=new p(a),a._chain=m),a}})}var m=!0,o=null,q=!1,X="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(u=global),exports),va={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},H=!{valueOf:0}.propertyIsEnumerable("valueOf"),za=0,J={"boolean":q,"function":m,object:m,number:q,string:q,"undefined":q},Aa=u._,z=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&" ).replace(/valueOf|for [^\]]+/g,".+?")+"$"),Ba=/__token__(\d+)/g,Ca=/['\n\r\t\u2028\u2029\\]/g,ca="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),T="__token__",w=[],I="[object Array]",la="[object Boolean]",ma="[object Date]",r="[object Function]",O="[object Number]",na="[object RegExp]",K="[object String]",A=Array.prototype,D=Object.prototype,M=A.concat,s=D.hasOwnProperty,L=A.push,l=A.slice,i=D.toString,y=z.test(y=l.bind)&&/\n|Opera/.test -(y+i.call(u.opera))&&y,E=z.test(E=Array.isArray)&&E,Da=u.isFinite,Y=z.test(Y=Object.keys)&&Y,Ea=u.clearTimeout,Q=u.setTimeout;b.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var sa=Function("n","var __p;with(obj){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" +(y+i.call(u.opera))&&y,E=z.test(E=Array.isArray)&&E,Da=u.isFinite,Y=z.test(Y=Object.keys)&&Y,Ea=u.clearTimeout,Q=u.setTimeout;b.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var sa=Function("obj","var __p;with(obj){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" ),t={a:"f,d,x",k:"f",q:"if(!d){d=k}else if(x){d=c(d,x)}",j:"d(f[l],l,f)"},Z={k:"z",j:"if(!d(f[l],l,f))return!r"},$={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ua?c():function(){if(1>--a)return c.apply(this,arguments)}},b.bind=v,b.bindAll=function(a){var c=arguments,d=1;1==c.length&&(d=0,c=P(a));for(var b=c.length;d Date: Tue, 29 May 2012 23:21:17 -0400 Subject: [PATCH 16/19] Bump to v0.2.2. Former-commit-id: c4516d1e2dd2ab4359233121a7f86c356425cebf --- README.md | 28 ++++++++++++++++++++++------ build.js | 6 +++--- doc/parse.php | 2 +- lodash.js | 4 ++-- lodash.min.js | 4 ++-- package.json | 2 +- 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 0b22084de4..2ff1ac76ec 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v0.2.1 +# Lo-Dash v0.2.2 A drop-in replacement for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), that delivers [performance improvements](http://jsperf.com/lodash-underscore#filterby=family), [bug fixes](https://github.com/bestiejs/lodash#closed-underscorejs-issues), and [additional features](https://github.com/bestiejs/lodash#features). @@ -36,18 +36,26 @@ Lo-Dash has been tested in at least Chrome 5-19, Firefox 1.5-12, IE 6-9, Opera 9 Custom builds make it easy to create lightweight versions of Lo-Dash containing only the methods you need. We handle all the method dependency and alias mapping for you. +Mobile builds, with IE bug fixes and method compilation removed, may be created by using the `mobile` argument. + +~~~ bash +node build mobile +~~~ + Custom builds may be created in two ways: 1. Use the`include` argument to pass the names of the methods to include in the build. ~~~ bash node build include=each,filter,map,noConflict node build include="each, filter, map, noConflict" +node build mobile include=each,filter,map,noConflict ~~~ 2. Use the `exclude` argument to pass the names of the methods to exclude from the build. ~~~ bash node build exclude=isNaN,isUndefined,union,zip node build exclude="isNaN, isUndefined, union, zip" +node build mobile exclude=isNaN,isUndefined,union,zip ~~~ Custom builds are saved to `lodash.custom.js` and `lodash.custom.min.js`. @@ -185,13 +193,21 @@ git submodule update --init ## Changelog +### v0.2.2 + + * Added mobile build option + * Ensured `_.find` returns `undefined` for unmatched values + * Ensured `_.templateSettings.variable` Underscore.js compatibility + * Optimized `_.escape` + * Reduced dependencies in `_.find` + ### v0.2.1 -* Adjusted the Lo-Dash export order for r.js -* Ensured `_.groupBy` values are added to own, not inherited, properties -* Made `_.bind` follow ES5 spec to support a popular Backbone.js pattern -* Removed the alias `intersect` -* Simplified `_.bind`, `_.flatten`, `_.groupBy`, `_.max`, and `_.min` + * Adjusted the Lo-Dash export order for r.js + * Ensured `_.groupBy` values are added to own, not inherited, properties + * Made `_.bind` follow ES5 spec to support a popular Backbone.js pattern + * Removed the alias `intersect` + * Simplified `_.bind`, `_.flatten`, `_.groupBy`, `_.max`, and `_.min` ### v0.2.0 diff --git a/build.js b/build.js index 9b5570f810..f570f7bdd9 100755 --- a/build.js +++ b/build.js @@ -10,6 +10,9 @@ var lodash = require(path.join(__dirname, 'lodash')), minify = require(path.join(__dirname, 'build', 'minify')); + /** Flag used to specify a mobile build */ + var isMobile = process.argv.indexOf('mobile') > -1; + /** Shortcut used to convert array-like objects to arrays */ var slice = [].slice; @@ -152,9 +155,6 @@ } }, ''); - /** Flag used to specify a mobile build */ - var isMobile = process.argv.indexOf('mobile') > -1; - /*--------------------------------------------------------------------------*/ /** diff --git a/doc/parse.php b/doc/parse.php index 48e5a55dde..bcb7b8c064 100644 --- a/doc/parse.php +++ b/doc/parse.php @@ -21,7 +21,7 @@ // generate Markdown $markdown = docdown(array( 'path' => '../' . $file, - 'title' => 'Lo-Dash v0.2.1', + 'title' => 'Lo-Dash v0.2.2', 'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js' )); diff --git a/lodash.js b/lodash.js index 2ca790a692..3a8e1b7dcd 100644 --- a/lodash.js +++ b/lodash.js @@ -1,5 +1,5 @@ /*! - * Lo-Dash v0.2.1 + * Lo-Dash v0.2.2 * Copyright 2012 John-David Dalton * Based on Underscore.js 1.3.3, copyright 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. * @@ -3089,7 +3089,7 @@ * @memberOf _ * @type String */ - lodash.VERSION = '0.2.1'; + lodash.VERSION = '0.2.2'; // assign static methods lodash.after = after; diff --git a/lodash.min.js b/lodash.min.js index 4bdb768c88..849f474721 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,5 +1,5 @@ /*! - Lo-Dash 0.2.1 lodash.com/license + Lo-Dash 0.2.2 lodash.com/license Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE */ ;(function(u,n){"use strict";function S(a){return"[object Arguments]"==i.call(a)}function b(a){return new p(a)}function p(a){if(a&&a._wrapped)return a;this._wrapped=a}function k(){for(var a,c,d,j=-1,b=arguments.length,e={e:"",f:"",k:"",q:"",c:{d:"",m:"++l/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var sa=Function("obj","var __p;with(obj){__p='var l,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;l=-1;';if(o){__p+='if(m===+m){'};__p+=''+c['d']+';while('+c['m']+'){'+c['j']+'}';if(o){__p+='}'}}if(o){if(c){__p+='else{'}if(!i){__p+='var s=typeof '+l+'==\\'function\\';'};__p+=''+o['d']+';for('+o['m']+'){';if(i){if(r){__p+='if('+h+'){'};__p+=''+o['j']+';';if(r){__p+='}'}}else{__p+='if(!(s&&l==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var g='+l+'.constructor;';for(var k=0;k<7;k++){__p+='l=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(g&&g.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" ),t={a:"f,d,x",k:"f",q:"if(!d){d=k}else if(x){d=c(d,x)}",j:"d(f[l],l,f)"},Z={k:"z",j:"if(!d(f[l],l,f))return!r"},$={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ua?c():function(){if(1>--a)return c.apply(this,arguments)}},b.bind=v,b.bindAll=function(a){var c=arguments,d=1;1==c.length&&(d=0,c=P(a));for(var b=c.length;da?c():function(){if(1>--a)return c.apply(this,arguments)}},b.bind=v,b.bindAll=function(a){var c=arguments,d=1;1==c.length&&(d=0,c=P(a));for(var b=c.length;dx(f,a[c])&&b.push(a[c]);return b},b.escape=function(a){return(a+"").replace(/&/g,"&").replace(/x(e,c)&&aa(f,function(a){return-1 Date: Wed, 30 May 2012 01:23:51 -0400 Subject: [PATCH 17/19] Cleanup README.md. Former-commit-id: b0d0a22ff427b6a5754e2850e2a420e764a1eb39 --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2ff1ac76ec..8564bd6140 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ For more information check out these screencasts over Lo-Dash: ## Features * AMD loader support - * [_.bind](http://lodash.com/docs#_bindfunc--arg1-arg2-) supports *"lazy"* binding - * [_.debounce](http://lodash.com/docs#_debouncefunc-wait-immediate)’ed functions match [_.throttle](http://lodash.com/docs#_throttlefunc-wait)’ed functions’ return value behavior - * [_.forEach](http://lodash.com/docs#_foreachcollection-callback--thisarg) is chainable - * [_.groupBy](http://lodash.com/docs#_groupbycollection-callback--thisarg) accepts a third, `thisArg`, argument - * [_.partial](http://lodash.com/docs#_partialfunc--arg1-arg2-) for more functional fun - * [_.size](http://lodash.com/docs#_sizecollection) supports returning the `length` of string values + * [_.bind](http://lodash.com/docs#bind) supports *"lazy"* binding + * [_.debounce](http://lodash.com/docs#debounce)’ed functions match [_.throttle](http://lodash.com/docs#throttle)’ed functions’ return value behavior + * [_.forEach](http://lodash.com/docs#forEach) is chainable + * [_.groupBy](http://lodash.com/docs#groupBy) accepts a third, `thisArg`, argument + * [_.partial](http://lodash.com/docs#partial) for more functional fun + * [_.size](http://lodash.com/docs#size) supports returning the `length` of string values ## Support @@ -197,7 +197,7 @@ git submodule update --init * Added mobile build option * Ensured `_.find` returns `undefined` for unmatched values - * Ensured `_.templateSettings.variable` Underscore.js compatibility + * Ensured `_.templateSettings.variable` is compatible with Underscore.js * Optimized `_.escape` * Reduced dependencies in `_.find` From 0d2a1641c97b8d17477bb9aba82dc749194914cc Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 30 May 2012 03:51:44 -0400 Subject: [PATCH 18/19] Add percent faster than to pref.js results and link to benchmarks in README.md. Former-commit-id: 1c5fb820fe070599aba780f1765538d408105af3 --- README.md | 2 +- perf/perf.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8564bd6140..8fd02e0d57 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Lo-Dash’s performance is gained by avoiding slower native methods, instead opt ## Dive in -We’ve got [API docs](http://lodash.com/docs) and [unit tests](http://lodash.com/tests). +We’ve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests). For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap). diff --git a/perf/perf.js b/perf/perf.js index 1bbba5dcb3..bfebe3cf77 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -99,8 +99,8 @@ lodashHz = underscoreHz = Math.min(lodashHz, underscoreHz); } else { - var slowestHz = slowest[0] == this[0] ? lodashHz : underscoreHz, - fastestHz = fastest[0] == this[0] ? lodashHz : underscoreHz, + var fastestHz = fastest[0] == this[0] ? lodashHz : underscoreHz, + slowestHz = slowest[0] == this[0] ? lodashHz : underscoreHz, percent = Math.round(((fastestHz / slowestHz) - 1) * 100); console.log(fastest[0].name + ' is ' + percent + '% faster.'); @@ -117,11 +117,17 @@ suites[0].run(); } else { + var fastestTotalHz = Math.max(score.lodash, score.underscore), + slowestTotalHz = Math.min(score.lodash, score.underscore), + totalPercent = Math.round(((fastestTotalHz / slowestTotalHz) - 1) * 100), + totalX = (fastestTotalHz / slowestTotalHz).toFixed(2), + message = ' is ' + totalPercent + '% (' + totalX + 'x) faster than '; + // report results if (score.lodash >= score.underscore) { - console.log('\nLo-Dash is ' + (score.lodash / score.underscore).toFixed(2) + 'x faster than Underscore.'); + console.log('\nLo-Dash' + message + 'Underscore.'); } else { - console.log('\nUnderscore is ' + (score.underscore / score.lodash).toFixed(2) + 'x faster than Lo-Dash.'); + console.log('\nUnderscore' + message + 'Lo-Dash.'); } } } From 548e9cac26bc28fc6f3d2d9cab59fcd3138b8d6f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 30 May 2012 03:52:59 -0400 Subject: [PATCH 19/19] Update documentation. Former-commit-id: 6d1aa50111b34e0548f96a55fe3dcca0b7e91b5e --- doc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index b7e324c35b..ad24053066 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v0.2.1 +# Lo-Dash v0.2.2