From 5e8c373bf439d7c678f79b7a1598995e2adbc9be Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 6 Jun 2012 22:28:17 -0400 Subject: [PATCH 01/16] Move `_.pluck` to the Arrays category. Former-commit-id: a3ba36c1c320c8685c25fcb0bbe16ba2baeb6731 --- build.js | 2 +- lodash.js | 61 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/build.js b/build.js index ba7c4fac67..c52cd0eda3 100755 --- a/build.js +++ b/build.js @@ -117,7 +117,7 @@ 'once': [], 'partial': [], 'pick': [], - 'pluck': ['createIterator'], + 'pluck': [], 'range': [], 'reduce': ['createIterator'], 'reduceRight': ['keys'], diff --git a/lodash.js b/lodash.js index 17e0cfcc82..e517793659 100644 --- a/lodash.js +++ b/lodash.js @@ -333,7 +333,7 @@ } }; - /** Reusable iterator options for `map`, `pluck`, and `values` */ + /** Reusable iterator options for `map` and `values` */ var mapIteratorOptions = { 'init': '', 'exit': 'if (!collection) return []', @@ -710,34 +710,6 @@ */ var map = createIterator(baseIteratorOptions, mapIteratorOptions); - /** - * Retrieves the value of a specified property from all values in a `collection`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object} collection The collection to iterate over. - * @param {String} property The property to pluck. - * @returns {Array} Returns a new array of property values. - * @example - * - * var stooges = [ - * { 'name': 'moe', 'age': 40 }, - * { 'name': 'larry', 'age': 50 }, - * { 'name': 'curly', 'age': 60 } - * ]; - * - * _.pluck(stooges, 'name'); - * // => ['moe', 'larry', 'curly'] - */ - var pluck = createIterator(mapIteratorOptions, { - 'args': 'collection, property', - 'inLoop': { - 'array': 'result[index] = collection[index][property]', - 'object': 'result.push(collection[index][property])' - } - }); - /** * 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 @@ -1418,6 +1390,37 @@ return result; } + /** + * Retrieves the value of a specified property from all elements in `array`. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to iterate over. + * @param {String} property The property to pluck. + * @returns {Array} Returns a new array of property values. + * @example + * + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 }, + * { 'name': 'curly', 'age': 60 } + * ]; + * + * _.pluck(stooges, 'name'); + * // => ['moe', 'larry', 'curly'] + */ + function pluck(array, property) { + var index = -1, + length = array.length, + result = Array(length); + + while (++index < length) { + result[index] = array[index][property]; + } + return result; + } + /** * 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 From ca1c732f31eaa6c525ed4bb4dce9d0706fd1367d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 6 Jun 2012 23:45:30 -0400 Subject: [PATCH 02/16] Move `_.values` to Objects category. Former-commit-id: e85229b53a7697c11f76eae02aef8a4fce3aec3a --- lodash.js | 97 ++++++++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 52 deletions(-) diff --git a/lodash.js b/lodash.js index e517793659..348459f556 100644 --- a/lodash.js +++ b/lodash.js @@ -333,20 +333,6 @@ } }; - /** Reusable iterator options for `map` and `values` */ - var mapIteratorOptions = { - 'init': '', - 'exit': 'if (!collection) return []', - 'beforeLoop': { - 'array': 'result = Array(length)', - 'object': 'result = []' - }, - 'inLoop': { - 'array': 'result[index] = callback(collection[index], index, collection)', - 'object': 'result.push(callback(collection[index], index, collection))' - } - }; - /*--------------------------------------------------------------------------*/ /** @@ -516,7 +502,7 @@ /** * A shim implementation of `Object.keys` that produces an array of the given - * object's enumerable own property names. + * object's own enumerable property names. * * @private * @param {Object} object The object to inspect. @@ -708,7 +694,18 @@ * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); * // => [3, 6, 9] (order is not guaranteed) */ - var map = createIterator(baseIteratorOptions, mapIteratorOptions); + var map = createIterator(baseIteratorOptions, { + 'init': '', + 'exit': 'if (!collection) return []', + 'beforeLoop': { + 'array': 'result = Array(length)', + 'object': 'result = []' + }, + 'inLoop': { + 'array': 'result[index] = callback(collection[index], index, collection)', + 'object': 'result.push(callback(collection[index], index, collection))' + } + }); /** * Boils down a `collection` to a single value. The initial state of the @@ -876,28 +873,6 @@ return values(collection); } - /** - * Produces an array of enumerable own property values of the `collection`. - * - * @static - * @memberOf _ - * @alias methods - * @category Collections - * @param {Array|Object} collection The collection to inspect. - * @returns {Array} Returns a new array of property values. - * @example - * - * _.values({ 'one': 1, 'two': 2, 'three': 3 }); - * // => [1, 2, 3] - */ - var values = createIterator(mapIteratorOptions, { - 'args': 'collection', - 'inLoop': { - 'array': 'result[index] = collection[index]', - 'object': 'result.push(collection[index])' - } - }); - /*--------------------------------------------------------------------------*/ /** @@ -2236,9 +2211,9 @@ var extend = createIterator(extendIteratorOptions); /** - * Iterates over an `object`'s enumerable own and inherited properties, - * executing the `callback` for each property. The `callback` is bound to - * `thisArg` and invoked with 3 arguments; (value, key, object). + * Iterates over `object`'s own and inherited enumerable properties, executing + * the `callback` for each property. The `callback` is bound to `thisArg` and + * invoked with 3 arguments; (value, key, object). * * @static * @memberOf _ @@ -2267,9 +2242,9 @@ }); /** - * Iterates over an `object`'s enumerable own properties, executing the - * `callback` for each property. The `callback` is bound to `thisArg` and - * invoked with 3 arguments; (value, key, object). + * Iterates over `object`'s own enumerable properties, executing the `callback` + * for each property. The `callback` is bound to `thisArg` and invoked with 3 + * arguments; (value, key, object). * * @static * @memberOf _ @@ -2288,8 +2263,8 @@ var forOwn = createIterator(baseIteratorOptions, forEachIteratorOptions, forOwnIteratorOptions); /** - * Produces a sorted array of the properties, own and inherited, of `object` - * that have function values. + * Produces a sorted array of the enumerable properties, own and inherited, + * of `object` that have function values. * * @static * @memberOf _ @@ -2428,7 +2403,7 @@ /** * Checks if a `value` is empty. Arrays or strings with a length of `0` and - * objects with no enumerable own properties are considered "empty". + * objects with no own enumerable properties are considered "empty". * * @static * @memberOf _ @@ -2792,7 +2767,7 @@ } /** - * Produces an array of the `object`'s enumerable own property names. + * Produces an array of object`'s own enumerable property names. * * @static * @memberOf _ @@ -2844,16 +2819,15 @@ } /** - * Gets the size of a `value` by returning `value.length` if `value` is a - * string or array, or the number of enumerable own properties if `value` is - * an object. + * Gets the size of `value` by returning `value.length` if `value` is a string + * or array, or the number of own enumerable properties if `value` is an object. * * @static * @memberOf _ * @category Objects * @param {Array|Object|String} value The value to inspect. * @returns {Number} Returns `value.length` if `value` is a string or array, - * or the number of enumerable own properties if `value` is an object. + * or the number of own enumerable properties if `value` is an object. * @example * * _.size([1, 2]); @@ -2898,6 +2872,25 @@ return value; } + /** + * Produces an array of `object`'s own enumerable property values. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to inspect. + * @returns {Array} Returns a new array of property values. + * @example + * + * _.values({ 'one': 1, 'two': 2, 'three': 3 }); + * // => [1, 2, 3] + */ + var values = createIterator({ + 'args': 'object', + 'init': '[]', + 'inLoop': 'result.push(object[index])' + }); + /*--------------------------------------------------------------------------*/ /** From c410c1293e8bd9151b0a913205cdbffcfa06e030 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 6 Jun 2012 23:48:41 -0400 Subject: [PATCH 03/16] Update minified build and documentation. Former-commit-id: e489b826c65d908b934e13d032ed866d68edd576 --- doc/README.md | 202 +++++++++++++++++++++++++------------------------- lodash.min.js | 55 +++++++------- 2 files changed, 128 insertions(+), 129 deletions(-) diff --git a/doc/README.md b/doc/README.md index 60f405c612..56d34ec84b 100644 --- a/doc/README.md +++ b/doc/README.md @@ -67,7 +67,7 @@ * [`_.once`](#_oncefunc) * [`_.partial`](#_partialfunc--arg1-arg2-) * [`_.pick`](#_pickobject--prop1-prop2-) -* [`_.pluck`](#_pluckcollection-property) +* [`_.pluck`](#_pluckarray-property) * [`_.range`](#_rangestart0-end--step1) * [`_.reduce`](#_reducecollection-callback--accumulator-thisarg) * [`_.reduceRight`](#_reducerightcollection-callback--accumulator-thisarg) @@ -87,7 +87,7 @@ * [`_.union`](#_unionarray1-array2-) * [`_.uniq`](#_uniqarray--issortedfalse-callbackidentity-thisarg) * [`_.uniqueId`](#_uniqueidprefix) -* [`_.values`](#_valuescollection) +* [`_.values`](#_valuesobject) * [`_.without`](#_withoutarray--value1-value2-) * [`_.wrap`](#_wrapfunc-wrapper--arg1-arg2-) * [`_.zip`](#_ziparray1-array2-) @@ -147,7 +147,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3271 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3267 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -159,7 +159,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1740 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1718 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -187,7 +187,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1772 "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`. @@ -238,7 +238,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1865 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1843 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -270,7 +270,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3223 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3219 "View in source") [Ⓣ][1] Wraps the value in a `lodash` chainable object. @@ -304,7 +304,7 @@ var youngest = _.chain(stooges) ### `_.clone(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2169 "View in source") [Ⓣ][1] Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned. @@ -328,7 +328,7 @@ _.clone({ 'name': 'moe' }); ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L945 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L892 "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. @@ -352,7 +352,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1897 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1875 "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()))`. @@ -379,7 +379,7 @@ welcome('moe'); ### `_.contains(collection, target)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L592 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L578 "View in source") [Ⓣ][1] Checks if a given `target` value is present in a `collection` using strict equality for comparisons, i.e. `===`. @@ -404,7 +404,7 @@ _.contains([1, 2, 3], 3); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1930 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1908 "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. @@ -430,7 +430,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, defaults1, defaults2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2192 "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. @@ -456,7 +456,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1995 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1973 "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. @@ -481,7 +481,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1975 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1953 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments are passed to `func` when it is invoked. @@ -508,7 +508,7 @@ _.delay(log, 1000, 'logged later'); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L974 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L921 "View in source") [Ⓣ][1] Produces a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -533,7 +533,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2914 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2910 "View in source") [Ⓣ][1] Escapes a string for inclusion in HTML, replacing `&`, `<`, `"`, and `'` characters. @@ -557,7 +557,7 @@ _.escape('Curly, Larry & Moe'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L617 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L603 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -583,7 +583,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2211 "View in source") [Ⓣ][1] Copies enumerable properties from the source objects to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -608,7 +608,7 @@ _.extend({ 'name': 'moe' }, { 'age': 40 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L638 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L624 "View in source") [Ⓣ][1] Examines each value in a `collection`, returning an array of all values the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -634,7 +634,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/v0.3.0/lodash.js#L660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L646 "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 bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -660,7 +660,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/v0.3.0/lodash.js#L1007 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L954 "View in source") [Ⓣ][1] Gets the first value of the `array`. Pass `n` to return the first `n` values of the `array`. @@ -686,7 +686,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L976 "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. @@ -714,7 +714,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.forEach(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L687 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L673 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each value in the `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -743,9 +743,9 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.forIn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2240 "View in source") [Ⓣ][1] -Iterates over an `object`'s enumerable own and inherited properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. +Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. #### Arguments 1. `object` *(Object)*: The object to iterate over. @@ -779,9 +779,9 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2285 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2263 "View in source") [Ⓣ][1] -Iterates over an `object`'s enumerable own properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. +Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. #### Arguments 1. `object` *(Object)*: The object to iterate over. @@ -807,9 +807,9 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2302 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2280 "View in source") [Ⓣ][1] -Produces a sorted array of the properties, own and inherited, of `object` that have function values. +Produces a sorted array of the enumerable properties, own and inherited, of `object` that have function values. #### Arguments 1. `object` *(Object)*: The object to inspect. @@ -831,7 +831,7 @@ _.functions(_); ### `_.groupBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1071 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1018 "View in source") [Ⓣ][1] Splits `array` into sets, grouped by the result of running each value through `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to group by. @@ -863,7 +863,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2325 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2303 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -888,7 +888,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2929 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -913,7 +913,7 @@ moe === _.identity(moe); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1165 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1112 "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. @@ -945,7 +945,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1202 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1149 "View in source") [Ⓣ][1] Gets all but the last value of the `array`. Pass `n` to exclude the last `n` values from the result. @@ -971,7 +971,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1167 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays. @@ -995,7 +995,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.invoke(array, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1256 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1203 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element of `array`. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element of `array`. @@ -1021,7 +1021,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2345 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2323 "View in source") [Ⓣ][1] Checks if a `value` is an `arguments` object. @@ -1048,7 +1048,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2371 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2349 "View in source") [Ⓣ][1] Checks if a `value` is an array. @@ -1075,7 +1075,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2388 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2366 "View in source") [Ⓣ][1] Checks if a `value` is a boolean *(`true` or `false`)* value. @@ -1099,7 +1099,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2405 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2383 "View in source") [Ⓣ][1] Checks if a `value` is a date. @@ -1123,7 +1123,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2422 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2400 "View in source") [Ⓣ][1] Checks if a `value` is a DOM element. @@ -1147,9 +1147,9 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2443 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2421 "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". +Checks if a `value` is empty. Arrays or strings with a length of `0` and objects with no own enumerable properties are considered "empty". #### Arguments 1. `value` *(Array|Object|String)*: The value to inspect. @@ -1174,7 +1174,7 @@ _.isEmpty({}); ### `_.isEqual(a, b [, stack])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2477 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2455 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -1206,7 +1206,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2629 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2607 "View in source") [Ⓣ][1] Checks if a `value` is a finite number. @@ -1236,7 +1236,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2624 "View in source") [Ⓣ][1] Checks if a `value` is a function. @@ -1260,7 +1260,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2675 "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. @@ -1293,7 +1293,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2719 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2697 "View in source") [Ⓣ][1] Checks if a `value` is `null`. @@ -1320,7 +1320,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2736 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2714 "View in source") [Ⓣ][1] Checks if a `value` is a number. @@ -1344,7 +1344,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2645 "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('')`) @@ -1371,7 +1371,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2753 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2731 "View in source") [Ⓣ][1] Checks if a `value` is a regular expression. @@ -1395,7 +1395,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2770 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2748 "View in source") [Ⓣ][1] Checks if a `value` is a string. @@ -1419,7 +1419,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2765 "View in source") [Ⓣ][1] Checks if a `value` is `undefined`. @@ -1443,9 +1443,9 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2782 "View in source") [Ⓣ][1] -Produces an array of the `object`'s enumerable own property names. +Produces an array of object`'s own enumerable property names. #### Arguments 1. `object` *(Object)*: The object to inspect. @@ -1467,7 +1467,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.last(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1286 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1233 "View in source") [Ⓣ][1] Gets the last value of the `array`. Pass `n` to return the lasy `n` values of the `array`. @@ -1493,7 +1493,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1310 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1257 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. @@ -1522,7 +1522,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L711 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L697 "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 `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1551,7 +1551,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1294 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1583,7 +1583,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2018 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1996 "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. @@ -1609,7 +1609,7 @@ var fibonacci = _.memoize(function(n) { ### `_.min(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1393 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1340 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1635,7 +1635,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2959 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2955 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1665,7 +1665,7 @@ _('larry').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2990 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2986 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1685,7 +1685,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2044 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2022 "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. @@ -1711,7 +1711,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2077 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2055 "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. @@ -1738,7 +1738,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2826 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2804 "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. @@ -1762,13 +1762,13 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); -### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L733 "View in source") [Ⓣ][1] +### `_.pluck(array, property)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1388 "View in source") [Ⓣ][1] -Retrieves the value of a specified property from all values in a `collection`. +Retrieves the value of a specified property from all elements in `array`. #### Arguments -1. `collection` *(Array|Object)*: The collection to iterate over. +1. `array` *(Array)*: The array to iterate over. 2. `property` *(String)*: The property to pluck. #### Returns @@ -1794,7 +1794,7 @@ _.pluck(stooges, 'name'); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1450 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1428 "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. @@ -1832,7 +1832,7 @@ _.range(0); ### `_.reduce(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L762 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L731 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*. @@ -1859,7 +1859,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L799 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L768 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1887,7 +1887,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L819 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1913,7 +1913,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/v0.3.0/lodash.js#L1486 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1464 "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. @@ -1939,7 +1939,7 @@ _.rest([3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3016 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. @@ -1974,7 +1974,7 @@ _.result(object, 'stuff'); ### `_.shuffle(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1504 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1482 "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. @@ -1998,15 +1998,15 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2865 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2842 "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 enumerable own properties if `value` is an object. +Gets the size of `value` by returning `value.length` if `value` is a string or array, or the number of own enumerable properties if `value` is an object. #### Arguments 1. `value` *(Array|Object|String)*: The value to inspect. #### Returns -*(Number)*: Returns `value.length` if `value` is a string or array, or the number of enumerable own properties if `value` is an object. +*(Number)*: Returns `value.length` if `value` is a string or array, or the number of own enumerable properties if `value` is an object. #### Example ~~~ js @@ -2028,7 +2028,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L874 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L843 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -2054,7 +2054,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1062 "View in source") [Ⓣ][1] Produces a new sorted array, ranked in ascending order by the results of running each element of `array` through `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -2086,7 +2086,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1553 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1531 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into the `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in the `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with `1` argument; *(value)*. @@ -2127,7 +2127,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) { ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2870 "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. @@ -2157,7 +2157,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3079 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3075 "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. @@ -2216,7 +2216,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' }); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2113 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2091 "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. @@ -2241,7 +2241,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3166 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3162 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*. @@ -2267,7 +2267,7 @@ _.times(3, function() { this.grantWish(); }, genie); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L862 "View in source") [Ⓣ][1] Converts the `collection`, into an array. Useful for converting the `arguments` object. @@ -2291,7 +2291,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1565 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays. @@ -2315,7 +2315,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1632 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1610 "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 bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -2351,7 +2351,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3193 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3189 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2374,13 +2374,13 @@ _.uniqueId('contact_'); -### `_.values(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L921 "View in source") [Ⓣ][1] +### `_.values(object)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2888 "View in source") [Ⓣ][1] -Produces an array of enumerable own property values of the `collection`. +Produces an array of `object`'s own enumerable property values. #### Arguments -1. `collection` *(Array|Object)*: The collection to inspect. +1. `object` *(Object)*: The object to inspect. #### Returns *(Array)*: Returns a new array of property values. @@ -2399,7 +2399,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1678 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1656 "View in source") [Ⓣ][1] Produces a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2424,7 +2424,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(func, wrapper [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2165 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2143 "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. @@ -2454,7 +2454,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1708 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1686 "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. @@ -2485,7 +2485,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3241 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3237 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2506,7 +2506,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3254 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. diff --git a/lodash.min.js b/lodash.min.js index 51ccc7b02c..36cbc839b2 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -2,31 +2,30 @@ Lo-Dash 0.3.0 lodash.com/license Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE */ -;(function(e,t){"use strict";function s(e){return"[object Arguments]"==nt.call(e)}function o(e){return new u(e)}function u(e){if(e&&e._wrapped)return e;this._wrapped=e}function a(){for(var e,t,s,o=-1,u=arguments.length,a={e:"",f:"",k:"",q:"",c:{d:"",m:"++k/g,evaluate:/<%([\s\S]+?)%>/g,interpolate -:/<%=([\s\S]+?)%>/g,variable:"obj"};var ft=Function("obj","var __p;with(obj){__p='var k,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;k=-1;';if(o){__p+='if(m===m>>>0){'};__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&&k==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var f='+l+'.constructor;';for(var k=0;k<7;k++){__p+='k=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(f&&f.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" -),lt={a:"e,c,x",k:"e",q:"if(!c){c=j}else if(x){c=l(c,x)}",j:"c(e[k],k,e)"},ct={k:"z",j:"if(!c(e[k],k,e))return!r"},ht={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ue?t():function(){if(1>--e)return t.apply(this,arguments -)}},o.bind=N,o.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=Ct(e));for(var r=t.length;nw(i,e[t])&&r.push(e[t]);return r},o.escape=function( -e){return(e+"").replace(H,c)},o.every=yt,o.extend=Nt,o.filter=G,o.find=bt,o.first=y,o.flatten=b,o.forEach=wt,o.forIn=ht,o.forOwn=lt,o.functions=Ct,o.groupBy=function(e,t,n){var r,i=-1,s="function"==typeof t,o=e.length,u={};for(s&&n&&(t=h(t,n));++iw(s,t)&&yt(i,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},o.map=Et,o.max=E,o.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Z.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},o.min=function(e,t,n){var r=Infinity,i=-1,s=e.length,o=r;if(!t){for(;++iarguments.length&&(t=e||0,e=0);for(var r=-1,i=Math. -max(Math.ceil((t-e)/n),0),s=Array(i);++ri?1:0}),"b")},o.sortedIndex=x,o.tap=function(e,t){return t(e),e},o.template=function(e,t,n){n||(n={});var i;i=o.templateSettings;var s=n.escape,u=n.evaluate,a=n.interpolate,n=n.variable;return s==r&&(s=i.escape),u==r&&(u=i.evaluate),a==r&&(a=i.interpolate),s&&(e=e.replace(s,d)),a&&(e=e.replace(a,v)),u&&(e=e.replace(u,m)),e="__p='"+e.replace(B,l).replace(P,f)+"';",I. -length=0,n||(n=i.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+e+"return __p}",i=Function("_","return "+e)(o),t?i(t):(i.source=e,i)},o.throttle=function(e,n){function r(){a=new Date,u=t,e.apply(o,i)}var i,s,o,u,a=0;return function(){var t=new Date,f=n-(t-a);return i=arguments,o=this,0>=f?(a=t,s=e.apply(o,i)):u||(u=at(r,f)),s}},o.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?tt.call(e):Tt(e)},o.union=function(){for(var e=-1,t=[],n=Y.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},o.uniq=T,o.uniqueId=function(e){var t=M++;return e?e+t:t},o.values=Tt,o.without=function(e){for(var t=tt.call(arguments,1),n=-1,r=e.length,i=[];++nw(t,e[n])&&i.push(e[n]);return i},o.wrap=function(e,t){return function(){var n=[e];return arguments -.length&&et.apply(n,arguments),t.apply(this,n)}},o.zip=function(){for(var e=-1,t=E(St(arguments,"length")),n=Array(t);++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var lt=Function("obj","var __p;with(obj){__p='var k,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;k=-1;';if(o){__p+='if(m===m>>>0){'};__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&&k==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var f='+l+'.constructor;';for(var k=0;k<7;k++){__p+='k=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(f&&f.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" +),ct={a:"e,c,x",k:"e",q:"if(!c){c=j}else if(x){c=l(c,x)}",j:"c(e[k],k,e)"},ht={k:"z",j:"if(!c(e[k],k,e))return!r"},pt={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ue?t():function(){if(1>--e)return t.apply(this,arguments)}},o.bind=C,o.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=Nt(e));for( +var r=t.length;nw(i,e[t])&&r.push(e[t]);return r},o.escape=function(e){return(e+"").replace(B,c)},o.every=yt,o.extend=Tt,o.filter=Y,o.find=bt,o.first= +y,o.flatten=b,o.forEach=wt,o.forIn=pt,o.forOwn=ct,o.functions=Nt,o.groupBy=function(e,t,n){var r,i=-1,s="function"==typeof t,o=e.length,u={};for(s&&n&&(t=h(t,n));++iw(s,t)&&yt(i,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if( +e[r]===t)return r;return-1},o.map=Et,o.max=E,o.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},o.min=function(e,t,n){var r=Infinity,i=-1,s=e.length,o=r;if(!t){for(;++iarguments.length&&(t=e||0,e=0);for(var r=-1,i=Math.max(Math.ceil((t-e)/n),0),s=Array(i);++ri?1:0}),"b")},o.sortedIndex=T,o.tap=function(e,t){return t(e),e},o.template=function(e,t,n){n||(n={});var i;i=o.templateSettings;var s=n.escape,u=n.evaluate,a=n.interpolate,n=n.variable;return s==r&&(s=i.escape),u==r&&(u=i.evaluate),a==r&&(a=i.interpolate),s&&(e=e.replace(s,d)),a&&(e=e.replace(a,v)),u&&(e=e.replace(u,m)),e="__p='"+e.replace(j,l).replace(H,f)+"';",q.length=0,n||(n=i.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+ +e+"return __p}",i=Function("_","return "+e)(o),t?i(t):(i.source=e,i)},o.throttle=function(e,n){function r(){a=new Date,u=t,e.apply(o,i)}var i,s,o,u,a=0;return function(){var t=new Date,f=n-(t-a);return i=arguments,o=this,0>=f?(a=t,s=e.apply(o,i)):u||(u=ft(r,f)),s}},o.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?nt.call(e):Lt(e)},o.union=function(){ +for(var e=-1,t=[],n=Z.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},o.uniq=N,o.uniqueId=function(e){var t=_++;return e?e+t:t},o.values=Lt,o.without=function(e){for(var t=nt.call(arguments,1),n=-1,r=e.length,i=[];++nw(t,e[n])&&i.push(e[n]);return i},o.wrap=function(e,t){return function(){var n=[e];return arguments.length&&tt.apply(n,arguments),t.apply(this,n)}},o.zip=function(){for(var e=-1,t=E(S(arguments,"length")),n=Array(t);++e Date: Thu, 7 Jun 2012 00:07:33 -0400 Subject: [PATCH 04/16] Fix typo in `_.values` benchmark and tweak how percents are displayed in perf.js. Former-commit-id: 49be4600561e55e134d3152b00c765e305af98b5 --- perf/perf.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/perf/perf.js b/perf/perf.js index e3f20c9d81..68bff8b283 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -149,9 +149,9 @@ else { var fastestHz = fastest[0] == this[0] ? lodashHz : underscoreHz, slowestHz = slowest[0] == this[0] ? lodashHz : underscoreHz, - percent = formatNumber(Math.round(((fastestHz / slowestHz) - 1) * 100)); + percent = ((fastestHz / slowestHz) - 1) * 100; - log(fastest[0].name + ' is ' + percent + '% faster.'); + log(fastest[0].name + ' is ' + formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) + '% faster.'); } // add score adjusted for margin of error score.lodash += lodashHz; @@ -604,10 +604,10 @@ suites.push( Benchmark.Suite('values') .add('Lo-Dash', function() { - lodash.values(objects); + lodash.values(object); }) .add('Underscore', function() { - _.values(objects); + _.values(object); }) ); From 5f2f15b9765d5f7eeff6a984955eb45bc8936e40 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 7 Jun 2012 03:27:01 -0400 Subject: [PATCH 05/16] Remove `_.isArguments` fallback from mobile build. Former-commit-id: d98ac9953e9b403e17bdcef099caafe09873980f --- build.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/build.js b/build.js index c52cd0eda3..1a7773c3e1 100755 --- a/build.js +++ b/build.js @@ -242,7 +242,7 @@ } /** - * Determines if all functions of the given names have been removed from the `source`. + * Determines if all functions of the given names have been removed from `source`. * * @private * @param {String} source The source to inspect. @@ -256,7 +256,7 @@ } /** - * Searches the `source` for a `funcName` function declaration, expression, or + * Searches `source` for a `funcName` function declaration, expression, or * assignment and returns the matched snippet. * * @private @@ -300,7 +300,7 @@ /** * Removes the `funcName` function declaration, expression, or assignment and - * associated code from the `source`. + * associated code from `source`. * * @private * @param {String} source The source to process. @@ -333,7 +333,18 @@ } /** - * Removes a given variable from the `source`. + * Removes the `_.isArguments` fallback from `source`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the source with the `isArguments` fallback removed. + */ + function removeIsArgumentsFallback(source) { + return source.replace(/(?: *\/\/.*)*\s*if *\(!isArguments[^)]+\)[\s\S]+?};?\s*}\n/, ''); + } + + /** + * Removes a given variable from `source`. * * @private * @param {String} source The source to process. @@ -409,8 +420,7 @@ // remove associated functions, variables and code snippets if (isRemoved(source, 'isArguments')) { - // remove `isArguments` if-statement - source = source.replace(/(?:\s*\/\/.*)*\s*if *\(!isArguments[^)]+\)[\s\S]+?};?\s*}\n/, ''); + source = removeIsArgumentsFallback(source); } if (isRemoved(source, 'mixin')) { // remove `LoDash` constructor @@ -477,7 +487,8 @@ source = source.replace(reFunc, '$1' + code + ';\n'); }); - // remove `iteratorTemplate` + source = removeIsArgumentsFallback(source); + source = removeVar(source, 'iteratorTemplate'); // remove JScript [[DontEnum]] fix from `isEqual` From 3c6999f3a4c04bf8fbe944a9b72b2ae1ded2bdd2 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 7 Jun 2012 12:42:24 -0400 Subject: [PATCH 06/16] Ensure all "Arrays" category methods allow a falsey `array` argument. [closes #23, #24] Former-commit-id: 66d09d3c8f3c045daf310c46581afa085daa57de --- lodash.js | 238 ++++++++++++++++++++++++++++++++------------------- test/test.js | 76 ++++++++++++++++ 2 files changed, 227 insertions(+), 87 deletions(-) diff --git a/lodash.js b/lodash.js index 348459f556..d24f6113e0 100644 --- a/lodash.js +++ b/lodash.js @@ -890,9 +890,12 @@ * // => [1, 2, 3] */ function compact(array) { + var result = []; + if (!array) { + return result; + } var index = -1, - length = array.length, - result = []; + length = array.length; while (++index < length) { if (array[index]) { @@ -919,9 +922,12 @@ * // => [1, 3, 4] */ function difference(array) { + var result = []; + if (!array) { + return result; + } var index = -1, length = array.length, - result = [], flattened = concat.apply(result, slice.call(arguments, 1)); while (++index < length) { @@ -945,14 +951,16 @@ * @param {Object} [guard] Internally used to allow this method to work with * others like `_.map` without using their callback `index` argument for `n`. * @returns {Mixed} Returns the first value or an array of the first `n` values - * of the `array`. + * of `array`. * @example * * _.first([5, 4, 3, 2, 1]); * // => 5 */ function first(array, n, guard) { - return (n == undefined || guard) ? array[0] : slice.call(array, 0, n); + if (array) { + return (n == undefined || guard) ? array[0] : slice.call(array, 0, n); + } } /** @@ -974,10 +982,13 @@ * // => [1, 2, 3, [[4]]]; */ function flatten(array, shallow) { + var result = []; + if (!array) { + return result; + } var value, index = -1, - length = array.length, - result = []; + length = array.length; while (++index < length) { value = array[index]; @@ -1016,12 +1027,15 @@ * // => { '3': ['one', 'two'], '5': ['three'] } */ function groupBy(array, callback, thisArg) { + var result = {}; + if (!array) { + return result; + } var prop, value, index = -1, isFunc = typeof callback == 'function', - length = array.length, - result = {}; + length = array.length; if (isFunc && thisArg) { callback = iteratorBind(callback, thisArg); @@ -1031,58 +1045,7 @@ prop = isFunc ? callback(value, index, array) : value[callback]; (hasOwnProperty.call(result, prop) ? result[prop] : result[prop] = []).push(value); } - return result - } - - /** - * Produces a new sorted array, ranked in ascending order by the results of - * running each element of `array` through `callback`. The `callback` is - * bound to `thisArg` and invoked with 3 arguments; (value, index, array). The - * `callback` argument may also be the name of a property to sort by (e.g. 'length'). - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to iterate over. - * @param {Function|String} callback The function called per iteration or - * property name to sort by. - * @param {Mixed} [thisArg] The `this` binding for the callback. - * @returns {Array} Returns a new array of sorted values. - * @example - * - * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); - * // => [3, 1, 2] - * - * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); - * // => [3, 1, 2] - * - * _.sortBy(['larry', 'brendan', 'moe'], 'length'); - * // => ['moe', 'larry', 'brendan'] - */ - function sortBy(array, callback, thisArg) { - if (typeof callback == 'string') { - var prop = callback; - callback = function(array) { return array[prop]; }; - } else if (thisArg) { - callback = iteratorBind(callback, thisArg); - } - return pluck(map(array, function(value, index) { - return { - 'criteria': callback(value, index, array), - 'value': value - }; - }).sort(function(left, right) { - var a = left.criteria, - b = right.criteria; - - if (a === undefined) { - return 1; - } - if (b === undefined) { - return -1; - } - return a < b ? -1 : a > b ? 1 : 0; - }), 'value'); + return result; } /** @@ -1110,6 +1073,9 @@ * // => 2 */ function indexOf(array, value, fromIndex) { + if (!array) { + return -1; + } var index = -1, length = array.length; @@ -1130,7 +1096,7 @@ } /** - * Gets all but the last value of the `array`. Pass `n` to exclude the last `n` + * Gets all but the last value of `array`. Pass `n` to exclude the last `n` * values from the result. * * @static @@ -1140,13 +1106,16 @@ * @param {Number} [n] The number of elements to return. * @param {Object} [guard] Internally used to allow this method to work with * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Array} Returns all but the last value or `n` values of the `array`. + * @returns {Array} Returns all but the last value or `n` values of `array`. * @example * * _.initial([3, 2, 1]); * // => [3, 2] */ function initial(array, n, guard) { + if (!array) { + return []; + } return slice.call(array, 0, -((n == undefined || guard) ? 1 : n)); } @@ -1165,11 +1134,14 @@ * // => [1, 2] */ function intersection(array) { + var result = []; + if (!array) { + return result; + } var value, index = -1, length = array.length, - others = slice.call(arguments, 1), - result = []; + others = slice.call(arguments, 1); while (++index < length) { value = array[index]; @@ -1201,11 +1173,14 @@ * // => [[1, 5, 7], [1, 2, 3]] */ function invoke(array, methodName) { + var result = []; + if (!array) { + return result; + } var args = slice.call(arguments, 2), index = -1, length = array.length, - isFunc = typeof methodName == 'function', - result = []; + isFunc = typeof methodName == 'function'; while (++index < length) { result[index] = (isFunc ? methodName : array[index][methodName]).apply(array[index], args); @@ -1224,15 +1199,18 @@ * @param {Number} [n] The number of elements to return. * @param {Object} [guard] Internally used to allow this method to work with * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Array} Returns all but the last value or `n` values of the `array`. + * @returns {Mixed} Returns the last value or an array of the last `n` values + * of `array`. * @example * * _.last([3, 2, 1]); * // => 1 */ function last(array, n, guard) { - var length = array.length; - return (n == undefined || guard) ? array[length - 1] : slice.call(array, -n || length); + if (array) { + var length = array.length; + return (n == undefined || guard) ? array[length - 1] : slice.call(array, -n || length); + } } /** @@ -1255,6 +1233,9 @@ * // => 1 */ function lastIndexOf(array, value, fromIndex) { + if (!array) { + return -1; + } var index = array.length; if (fromIndex && typeof fromIndex == 'number') { index = (fromIndex < 0 ? Math.max(0, index + fromIndex) : Math.min(fromIndex, index - 1)) + 1; @@ -1292,11 +1273,15 @@ * // => { 'name': 'curly', 'age': 60 }; */ function max(array, callback, thisArg) { + var computed = -Infinity, + result = computed; + + if (!array) { + return result; + } var current, - computed = -Infinity, index = -1, - length = array.length, - result = computed; + length = array.length; if (!callback) { while (++index < length) { @@ -1338,11 +1323,15 @@ * // => 2 */ function min(array, callback, thisArg) { + var computed = Infinity, + result = computed; + + if (!array) { + return result; + } var current, - computed = Infinity, index = -1, - length = array.length, - result = computed; + length = array.length; if (!callback) { while (++index < length) { @@ -1386,6 +1375,9 @@ * // => ['moe', 'larry', 'curly'] */ function pluck(array, property) { + if (!array) { + return []; + } var index = -1, length = array.length, result = Array(length); @@ -1445,7 +1437,7 @@ /** * 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. + * `array`. Pass `n` to exclude the first `n` values from the result. * * @static * @memberOf _ @@ -1455,13 +1447,16 @@ * @param {Number} [n] The number of elements to return. * @param {Object} [guard] Internally used to allow this method to work with * others like `_.map` without using their callback `index` argument for `n`. - * @returns {Array} Returns all but the first value or `n` values of the `array`. + * @returns {Array} Returns all but the first value or `n` values of `array`. * @example * * _.rest([3, 2, 1]); * // => [2, 1] */ function rest(array, n, guard) { + if (!array) { + return []; + } return slice.call(array, (n == undefined || guard) ? 1 : n); } @@ -1480,6 +1475,9 @@ * // => [4, 1, 6, 3, 5, 2] */ function shuffle(array) { + if (!array) { + return []; + } var rand, index = -1, length = array.length, @@ -1493,12 +1491,66 @@ return result; } + /** + * Produces a new sorted array, ranked in ascending order by the results of + * running each element of `array` through `callback`. The `callback` is + * bound to `thisArg` and invoked with 3 arguments; (value, index, array). The + * `callback` argument may also be the name of a property to sort by (e.g. 'length'). + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to iterate over. + * @param {Function|String} callback The function called per iteration or + * property name to sort by. + * @param {Mixed} [thisArg] The `this` binding for the callback. + * @returns {Array} Returns a new array of sorted values. + * @example + * + * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); + * // => [3, 1, 2] + * + * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); + * // => [3, 1, 2] + * + * _.sortBy(['larry', 'brendan', 'moe'], 'length'); + * // => ['moe', 'larry', 'brendan'] + */ + function sortBy(array, callback, thisArg) { + if (!array) { + return []; + } + if (typeof callback == 'string') { + var prop = callback; + callback = function(array) { return array[prop]; }; + } else if (thisArg) { + callback = iteratorBind(callback, thisArg); + } + return pluck(map(array, function(value, index) { + return { + 'criteria': callback(value, index, array), + 'value': value + }; + }).sort(function(left, right) { + var a = left.criteria, + b = right.criteria; + + if (a === undefined) { + return 1; + } + if (b === undefined) { + return -1; + } + return a < b ? -1 : a > b ? 1 : 0; + }), 'value'); + } + /** * Uses a binary search to determine the smallest index at which the `value` - * should be inserted into the `array` in order to maintain the sort order - * of the sorted `array`. If `callback` is passed, it will be executed for - * `value` and each element in the `array` to compute their sort ranking. - * The `callback` is bound to `thisArg` and invoked with 1 argument; (value). + * should be inserted into `array` in order to maintain the sort order of the + * sorted `array`. If `callback` is passed, it will be executed for `value` and + * each element in `array` to compute their sort ranking. The `callback` is + * bound to `thisArg` and invoked with 1 argument; (value). * * @static * @memberOf _ @@ -1508,7 +1560,7 @@ * @param {Function} [callback=identity] The function called per iteration. * @param {Mixed} [thisArg] The `this` binding for the callback. * @returns {Number} Returns the index at which the value should be inserted - * into the array. + * into `array`. * @example * * _.sortedIndex([20, 30, 40], 35); @@ -1529,6 +1581,9 @@ * // => 2 */ function sortedIndex(array, value, callback, thisArg) { + if (!array) { + return 0; + } var mid, low = 0, high = array.length; @@ -1608,10 +1663,13 @@ * // => [1, 2, 3] */ function uniq(array, isSorted, callback, thisArg) { + var result = []; + if (!array) { + return result; + } var computed, index = -1, length = array.length, - result = [], seen = []; // juggle arguments @@ -1654,10 +1712,13 @@ * // => [2, 3, 4] */ function without(array) { + var result = []; + if (!array) { + return result; + } var excluded = slice.call(arguments, 1), index = -1, - length = array.length, - result = []; + length = array.length; while (++index < length) { if (indexOf(excluded, array[index]) < 0) { @@ -1683,7 +1744,10 @@ * _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); * // => [['moe', 30, true], ['larry', 40, false], ['curly', 50, false]] */ - function zip() { + function zip(array) { + if (!array) { + return []; + } var index = -1, length = max(pluck(arguments, 'length')), result = Array(length); diff --git a/test/test.js b/test/test.js index b62b26227d..1c27d23b1d 100644 --- a/test/test.js +++ b/test/test.js @@ -708,6 +708,82 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash "Arrays" methods'); + + (function() { + test('should allow a falsey `array` argument', function() { + _.each([ + 'compact', + 'difference', + 'first', + 'flatten', + 'groupBy', + 'indexOf', + 'initial', + 'intersection', + 'invoke', + 'last', + 'lastIndexOf', + 'max', + 'min', + 'pluck', + 'range', + 'rest', + 'shuffle', + 'sortBy', + 'sortedIndex', + 'union', + 'uniq', + 'without', + 'zip' + ], function(methodName) { + var pass = true; + try { + _[methodName](); + } catch(e) { + pass = false; + } + ok(pass, methodName + ' allows a falsey `array` argument'); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('lodash "Collections" methods'); + + (function() { + test('should allow a falsey `collection` argument', function() { + _.each([ + 'contains', + 'every', + 'filter', + 'find', + 'forEach', + 'map', + 'reduce', + 'reduceRight', + 'reject', + 'some', + 'toArray' + ], function(methodName) { + var pass = true; + try { + if (/^(?:contains|toArray)$/.test(methodName)) { + _[methodName](null); + } else { + _[methodName](null, _.identity); + } + } catch(e) { + pass = false; + } + ok(pass, methodName + ' allows a falsey `collection` argument'); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + // explicitly call `QUnit.start()` for Narwhal, Rhino, and RingoJS QUnit.start(); From 2332245be1fed1dbb6c17c98e3c3b9d963eab6c3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 7 Jun 2012 12:44:53 -0400 Subject: [PATCH 07/16] Update minified build and documentation. Former-commit-id: 6790d25b2164f0df2dcce63d5a5780343f3b5e63 --- doc/README.md | 164 +++++++++++++++++++++++++------------------------- lodash.min.js | 45 +++++++------- 2 files changed, 105 insertions(+), 104 deletions(-) diff --git a/doc/README.md b/doc/README.md index 56d34ec84b..9d32e844ac 100644 --- a/doc/README.md +++ b/doc/README.md @@ -147,7 +147,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3267 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3331 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -159,7 +159,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1718 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1782 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -187,7 +187,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1836 "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`. @@ -238,7 +238,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1843 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1907 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -270,7 +270,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3219 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3283 "View in source") [Ⓣ][1] Wraps the value in a `lodash` chainable object. @@ -304,7 +304,7 @@ var youngest = _.chain(stooges) ### `_.clone(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2169 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2233 "View in source") [Ⓣ][1] Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned. @@ -352,7 +352,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1875 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1939 "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()))`. @@ -404,7 +404,7 @@ _.contains([1, 2, 3], 3); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1908 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1972 "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. @@ -430,7 +430,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, defaults1, defaults2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2192 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2256 "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. @@ -456,7 +456,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1973 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2037 "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. @@ -481,7 +481,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1953 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2017 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments are passed to `func` when it is invoked. @@ -508,7 +508,7 @@ _.delay(log, 1000, 'logged later'); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L921 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L924 "View in source") [Ⓣ][1] Produces a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -533,7 +533,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2910 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2974 "View in source") [Ⓣ][1] Escapes a string for inclusion in HTML, replacing `&`, `<`, `"`, and `'` characters. @@ -583,7 +583,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2211 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2275 "View in source") [Ⓣ][1] Copies enumerable properties from the source objects to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -660,7 +660,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/v0.3.0/lodash.js#L954 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L960 "View in source") [Ⓣ][1] Gets the first value of the `array`. Pass `n` to return the first `n` values of the `array`. @@ -670,7 +670,7 @@ Gets the first value of the `array`. Pass `n` to return the first `n` values of 3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`. #### Returns -*(Mixed)*: Returns the first value or an array of the first `n` values of the `array`. +*(Mixed)*: Returns the first value or an array of the first `n` values of `array`. #### Example ~~~ js @@ -686,7 +686,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L976 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L984 "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. @@ -743,7 +743,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.forIn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2304 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. @@ -779,7 +779,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2263 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2327 "View in source") [Ⓣ][1] Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. @@ -807,7 +807,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2280 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2344 "View in source") [Ⓣ][1] Produces a sorted array of the enumerable properties, own and inherited, of `object` that have function values. @@ -831,7 +831,7 @@ _.functions(_); ### `_.groupBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1018 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1029 "View in source") [Ⓣ][1] Splits `array` into sets, grouped by the result of running each value through `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to group by. @@ -863,7 +863,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2303 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2367 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -888,7 +888,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2929 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2993 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -913,7 +913,7 @@ moe === _.identity(moe); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1112 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1075 "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. @@ -945,9 +945,9 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1115 "View in source") [Ⓣ][1] -Gets all but the last value of the `array`. Pass `n` to exclude the last `n` values from the result. +Gets all but the last value of `array`. Pass `n` to exclude the last `n` values from the result. #### Arguments 1. `array` *(Array)*: The array to query. @@ -955,7 +955,7 @@ Gets all but the last value of the `array`. Pass `n` to exclude the last `n` val 3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`. #### Returns -*(Array)*: Returns all but the last value or `n` values of the `array`. +*(Array)*: Returns all but the last value or `n` values of `array`. #### Example ~~~ js @@ -971,7 +971,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1136 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays. @@ -995,7 +995,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.invoke(array, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1203 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1175 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element of `array`. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element of `array`. @@ -1021,7 +1021,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2323 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2387 "View in source") [Ⓣ][1] Checks if a `value` is an `arguments` object. @@ -1048,7 +1048,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2349 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2413 "View in source") [Ⓣ][1] Checks if a `value` is an array. @@ -1075,7 +1075,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2430 "View in source") [Ⓣ][1] Checks if a `value` is a boolean *(`true` or `false`)* value. @@ -1099,7 +1099,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2383 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2447 "View in source") [Ⓣ][1] Checks if a `value` is a date. @@ -1123,7 +1123,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2400 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2464 "View in source") [Ⓣ][1] Checks if a `value` is a DOM element. @@ -1147,7 +1147,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2421 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2485 "View in source") [Ⓣ][1] Checks if a `value` is empty. Arrays or strings with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -1174,7 +1174,7 @@ _.isEmpty({}); ### `_.isEqual(a, b [, stack])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2455 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2519 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -1206,7 +1206,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2607 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2671 "View in source") [Ⓣ][1] Checks if a `value` is a finite number. @@ -1236,7 +1236,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2688 "View in source") [Ⓣ][1] Checks if a `value` is a function. @@ -1260,7 +1260,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2675 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2739 "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. @@ -1293,7 +1293,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2761 "View in source") [Ⓣ][1] Checks if a `value` is `null`. @@ -1320,7 +1320,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2778 "View in source") [Ⓣ][1] Checks if a `value` is a number. @@ -1344,7 +1344,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2645 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2709 "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('')`) @@ -1371,7 +1371,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2731 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2795 "View in source") [Ⓣ][1] Checks if a `value` is a regular expression. @@ -1395,7 +1395,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2748 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2812 "View in source") [Ⓣ][1] Checks if a `value` is a string. @@ -1419,7 +1419,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2765 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2829 "View in source") [Ⓣ][1] Checks if a `value` is `undefined`. @@ -1443,7 +1443,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2782 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2846 "View in source") [Ⓣ][1] Produces an array of object`'s own enumerable property names. @@ -1467,7 +1467,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.last(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/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`. @@ -1477,7 +1477,7 @@ Gets the last value of the `array`. Pass `n` to return the lasy `n` values of th 3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`. #### Returns -*(Array)*: Returns all but the last value or `n` values of the `array`. +*(Mixed)*: Returns the last value or an array of the last `n` values of `array`. #### Example ~~~ js @@ -1493,7 +1493,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1257 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1235 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. @@ -1551,7 +1551,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1294 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1275 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1583,7 +1583,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1996 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2060 "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. @@ -1609,7 +1609,7 @@ var fibonacci = _.memoize(function(n) { ### `_.min(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1340 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1325 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1635,7 +1635,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3019 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1665,7 +1665,7 @@ _('larry').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2986 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3050 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1685,7 +1685,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2022 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2086 "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. @@ -1711,7 +1711,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2055 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2119 "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. @@ -1738,7 +1738,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2868 "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. @@ -1763,7 +1763,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); ### `_.pluck(array, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1388 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1377 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in `array`. @@ -1794,7 +1794,7 @@ _.pluck(stooges, 'name'); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1428 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1420 "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. @@ -1913,9 +1913,9 @@ 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/v0.3.0/lodash.js#L1464 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1456 "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. +The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. #### Arguments 1. `array` *(Array)*: The array to query. @@ -1923,7 +1923,7 @@ The opposite of `_.initial`, this method gets all but the first value of the `ar 3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`. #### Returns -*(Array)*: Returns all but the first value or `n` values of the `array`. +*(Array)*: Returns all but the first value or `n` values of `array`. #### Example ~~~ js @@ -1939,7 +1939,7 @@ _.rest([3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3016 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3080 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. @@ -1974,7 +1974,7 @@ _.result(object, 'stuff'); ### `_.shuffle(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1482 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1477 "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. @@ -1998,7 +1998,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2906 "View in source") [Ⓣ][1] Gets the size of `value` by returning `value.length` if `value` is a string or array, or the number of own enumerable properties if `value` is an object. @@ -2054,7 +2054,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1519 "View in source") [Ⓣ][1] Produces a new sorted array, ranked in ascending order by the results of running each element of `array` through `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -2086,9 +2086,9 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1531 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1583 "View in source") [Ⓣ][1] -Uses a binary search to determine the smallest index at which the `value` should be inserted into the `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in the `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with `1` argument; *(value)*. +Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with `1` argument; *(value)*. #### Arguments 1. `array` *(Array)*: The array to iterate over. @@ -2097,7 +2097,7 @@ Uses a binary search to determine the smallest index at which the `value` should 4. `[thisArg]` *(Mixed)*: The `this` binding for the callback. #### Returns -*(Number)*: Returns the index at which the value should be inserted into the array. +*(Number)*: Returns the index at which the value should be inserted into `array`. #### Example ~~~ js @@ -2127,7 +2127,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) { ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2934 "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. @@ -2157,7 +2157,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3075 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3139 "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. @@ -2216,7 +2216,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' }); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2091 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2155 "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. @@ -2241,7 +2241,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3226 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*. @@ -2291,7 +2291,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1565 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1620 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays. @@ -2315,7 +2315,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1610 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1665 "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 bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -2351,7 +2351,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3189 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3253 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2375,7 +2375,7 @@ _.uniqueId('contact_'); ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2888 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2952 "View in source") [Ⓣ][1] Produces an array of `object`'s own enumerable property values. @@ -2399,7 +2399,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1656 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1714 "View in source") [Ⓣ][1] Produces a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2424,7 +2424,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(func, wrapper [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2143 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2207 "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. @@ -2454,7 +2454,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1686 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1747 "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. @@ -2485,7 +2485,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3237 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3301 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2506,7 +2506,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3254 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3318 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. diff --git a/lodash.min.js b/lodash.min.js index 36cbc839b2..40efffe218 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -4,28 +4,29 @@ */ ;(function(e,t){"use strict";function s(e){return"[object Arguments]"==rt.call(e)}function o(e){return new u(e)}function u(e){if(e&&e._wrapped)return e;this._wrapped=e}function a(){for(var e,t,s,o=-1,u=arguments.length,a={e:"",f:"",k:"",q:"",c:{d:"",m:"++k/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var lt=Function("obj","var __p;with(obj){__p='var k,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;k=-1;';if(o){__p+='if(m===m>>>0){'};__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&&k==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var f='+l+'.constructor;';for(var k=0;k<7;k++){__p+='k=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(f&&f.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" +;return q[n]="'+((__t=("+t+"))==null?'':__t)+'",I+n}function m(e,t){var n=q.length;return q[n]="';"+t+";__p+='",I+n}function g(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=h(t,r));if(i===i>>>0){for(i&&s&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}var o=kt(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function y(e,n,r){if(e)return n==t||r?e[0]:nt.call(e,0,n)}function b(e,t){var n=[];if(!e)return n;for(var r,i=-1,s=e.length;++in?Math.max(0,i+n):n)-1}for(;++ri&&(i=e[s]);return i}for(n&&(t=h(t,n));++sr&&(r=n,i=e[s]);return i}function S(e,t){if(!e)return[];for(var n=-1,r=e.length,i=Array(r);++n>>1,n.call(r,e[i])>>1,e[i]w(a,r))a.push(r),s.push(e[o]);return s}function C(e,t){function n(){var u=arguments,a=t;return s||(e=t[i]), +o.length&&(u=u.length?Z.apply(o,u):o),this instanceof n?(p.prototype=e.prototype,a=new p,u=e.apply(a,u),U[typeof u]&&u!==r?u:a):e.apply(a,u)}var i,s=rt.call(e)==$;if(s){if(it)return it.call.apply(it,arguments)}else i=t,t=e;var o=nt.call(arguments,2);return n}function k(e,r,s){s||(s=[]);if(e===r)return 0!==e||1/e==1/r;if(e==t||r==t)return e===r;e._chain&&(e=e._wrapped),r._chain&&(r=r._wrapped);if(e.isEqual&&rt.call(e.isEqual)==$)return e.isEqual(r);if(r.isEqual&&rt.call(r.isEqual)==$)return r.isEqual +(e);var o=rt.call(e);if(o!=rt.call(r))return i;switch(o){case Q:return e==""+r;case J:return e!=+e?r!=+r:0==e?1/e==1/r:e==+r;case X:case V:return+e==+r;case K:return e.source==r.source&&e.global==r.global&&e.multiline==r.multiline&&e.ignoreCase==r.ignoreCase}if("object"!=typeof e||"object"!=typeof r)return i;for(var u=s.length;u--;)if(s[u]==e)return n;var u=-1,a=n,f=0;s.push(e);if(o==W){if(f=e.length,a=f==r.length)for(;f--&&(a=k(e[f],r[f],s)););}else{if("constructor"in e!="constructor"in r||e.constructor!= +r.constructor)return i;for(var l in e)if(et.call(e,l)&&(f++,!(a=et.call(r,l)&&k(e[l],r[l],s))))break;if(a){for(l in r)if(et.call(r,l)&&!(f--))break;a=!f}if(a&&M)for(;7>++u&&(l=F[u],!et.call(e,l)||!!(a=et.call(r,l)&&k(e[l],r[l],s))););}return s.pop(),a}function L(e){return e}function A(e){wt(Nt(e),function(t){var r=o[t]=e[t];u.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&tt.apply(e,arguments),e=1==e.length?r.call(o,e[0]):r.apply(o,e),this._chain&&(e=new u(e),e._chain=n),e +}})}var n=!0,r=null,i=!1,O="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(e=global),exports),M=!{valueOf:0}.propertyIsEnumerable("valueOf"),_=0,D=e._,P=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),H=/__token__(\d+)/g,B=/[&<"']/g,j=/['\n\r\t\u2028\u2029\\]/g,F="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),I="__token__",q=[],R= +{"&":"&","<":"<",'"':""","'":"'"},U={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},W="[object Array]",X="[object Boolean]",V="[object Date]",$="[object Function]",J="[object Number]",K="[object RegExp]",Q="[object String]",G=Array.prototype,Y=Object.prototype,Z=G.concat,et=Y.hasOwnProperty,tt=G.push,nt=G.slice,rt=Y.toString,it=P.test(it=nt.bind)&&/\n|Opera/.test(it+rt.call(e.opera +))&&it,st=P.test(st=Array.isArray)&&st,ot=e.isFinite,ut=P.test(ut=Object.keys)&&ut,at=e.clearTimeout,ft=e.setTimeout;o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var lt=Function("obj","var __p;with(obj){__p='var k,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;k=-1;';if(o){__p+='if(m===m>>>0){'};__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&&k==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var f='+l+'.constructor;';for(var k=0;k<7;k++){__p+='k=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(f&&f.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" ),ct={a:"e,c,x",k:"e",q:"if(!c){c=j}else if(x){c=l(c,x)}",j:"c(e[k],k,e)"},ht={k:"z",j:"if(!c(e[k],k,e))return!r"},pt={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ue?t():function(){if(1>--e)return t.apply(this,arguments)}},o.bind=C,o.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=Nt(e));for( -var r=t.length;nw(i,e[t])&&r.push(e[t]);return r},o.escape=function(e){return(e+"").replace(B,c)},o.every=yt,o.extend=Tt,o.filter=Y,o.find=bt,o.first= -y,o.flatten=b,o.forEach=wt,o.forIn=pt,o.forOwn=ct,o.functions=Nt,o.groupBy=function(e,t,n){var r,i=-1,s="function"==typeof t,o=e.length,u={};for(s&&n&&(t=h(t,n));++iw(s,t)&&yt(i,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if( -e[r]===t)return r;return-1},o.map=Et,o.max=E,o.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},o.min=function(e,t,n){var r=Infinity,i=-1,s=e.length,o=r;if(!t){for(;++iarguments.length&&(t=e||0,e=0);for(var r=-1,i=Math.max(Math.ceil((t-e)/n),0),s=Array(i);++ri?1:0}),"b")},o.sortedIndex=T,o.tap=function(e,t){return t(e),e},o.template=function(e,t,n){n||(n={});var i;i=o.templateSettings;var s=n.escape,u=n.evaluate,a=n.interpolate,n=n.variable;return s==r&&(s=i.escape),u==r&&(u=i.evaluate),a==r&&(a=i.interpolate),s&&(e=e.replace(s,d)),a&&(e=e.replace(a,v)),u&&(e=e.replace(u,m)),e="__p='"+e.replace(j,l).replace(H,f)+"';",q.length=0,n||(n=i.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+ -e+"return __p}",i=Function("_","return "+e)(o),t?i(t):(i.source=e,i)},o.throttle=function(e,n){function r(){a=new Date,u=t,e.apply(o,i)}var i,s,o,u,a=0;return function(){var t=new Date,f=n-(t-a);return i=arguments,o=this,0>=f?(a=t,s=e.apply(o,i)):u||(u=ft(r,f)),s}},o.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?nt.call(e):Lt(e)},o.union=function(){ -for(var e=-1,t=[],n=Z.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},o.uniq=N,o.uniqueId=function(e){var t=_++;return e?e+t:t},o.values=Lt,o.without=function(e){for(var t=nt.call(arguments,1),n=-1,r=e.length,i=[];++nw(t,e[n])&&i.push(e[n]);return i},o.wrap=function(e,t){return function(){var n=[e];return arguments.length&&tt.apply(n,arguments),t.apply(this,n)}},o.zip=function(){for(var e=-1,t=E(S(arguments,"length")),n=Array(t);++ew(i,e[n])&&t.push(e[n]);return t},o.escape=function(e){return(e+"").replace(B,c)},o.every=yt,o.extend=Tt +,o.filter=Y,o.find=bt,o.first=y,o.flatten=b,o.forEach=wt,o.forIn=pt,o.forOwn=ct,o.functions=Nt,o.groupBy=function(e,t,n){var r={};if(!e)return r;var i,s=-1,o="function"==typeof t,u=e.length;for(o&&n&&(t=h(t,n));++sw(t,n)&&yt(s,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},o.map=Et,o.max=E,o.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},o.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s +arguments.length&&(t=e||0,e=0);for(var r=-1,i=Math.max(Math.ceil((t-e)/n),0),s=Array(i);++ri?1:0}),"b")},o.sortedIndex=T,o.tap=function(e,t){return t(e),e},o.template=function(e,t,n){n||(n={});var i;i=o.templateSettings;var s=n.escape,u=n.evaluate,a=n.interpolate,n=n.variable;return s==r&&(s=i.escape),u==r&&(u=i.evaluate),a==r&&(a=i.interpolate),s&&(e=e.replace(s,d)),a&&(e=e. +replace(a,v)),u&&(e=e.replace(u,m)),e="__p='"+e.replace(j,l).replace(H,f)+"';",q.length=0,n||(n=i.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+e+"return __p}",i=Function("_","return "+e)(o),t?i(t):(i.source=e,i)},o.throttle=function(e,n){function r(){a=new Date,u=t,e.apply(o,i)}var i,s,o,u,a=0;return function(){var t=new Date,f=n-(t-a);return i=arguments,o=this,0>=f?(a=t,s=e.apply(o,i)):u||(u=ft(r,f)),s +}},o.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?nt.call(e):Lt(e)},o.union=function(){for(var e=-1,t=[],n=Z.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},o.uniq=N,o.uniqueId=function(e){var t=_++;return e?e+t:t},o.values=Lt,o.without=function(e){var t=[];if(!e)return t;for(var n=nt.call(arguments,1),r=-1,i=e.length;++rw(n,e[r])&&t.push(e[r]);return t},o.wrap=function(e,t){return function(){var n=[e];return arguments.length&&tt.apply(n,arguments),t.apply(this,n)}},o.zip=function(e){if(!e)return[];for(var t=-1,n=E(S(arguments,"length")),r=Array(n);++t Date: Sat, 9 Jun 2012 00:29:51 -0400 Subject: [PATCH 08/16] Remove `_.map` and `_.pluck` dependency from `_.sortBy` and simplify method wrappers. Former-commit-id: 915af96abd41e8da7bba88cd57eb703f8129107f --- build/pre-compile.js | 4 ++-- lodash.js | 37 ++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 18c34b43c6..17bc43bced 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -226,9 +226,9 @@ result = snippet; if (snippet) { - // minify property strings + // minify properties properties.forEach(function(property, index) { - result = result.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'"); + result = result.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]); }); // replace with modified snippet source = source.replace(snippet, result); diff --git a/lodash.js b/lodash.js index d24f6113e0..98d8931319 100644 --- a/lodash.js +++ b/lodash.js @@ -1526,12 +1526,17 @@ } else if (thisArg) { callback = iteratorBind(callback, thisArg); } - return pluck(map(array, function(value, index) { - return { - 'criteria': callback(value, index, array), - 'value': value + var index = -1, + length = array.length, + result = Array(length); + + while (++index < length) { + result[index] = { + 'criteria': callback(array[index], index, array), + 'value': array[index] }; - }).sort(function(left, right) { + } + result.sort(function(left, right) { var a = left.criteria, b = right.criteria; @@ -1542,7 +1547,12 @@ return -1; } return a < b ? -1 : a > b ? 1 : 0; - }), 'value'); + }); + + while (length--) { + result[length] = result[length].value; + } + return result; } /** @@ -1921,7 +1931,7 @@ /** * 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()))`. + * In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. * * @static * @memberOf _ @@ -3025,7 +3035,7 @@ if (arguments.length) { push.apply(args, arguments); } - var result = args.length == 1 ? func.call(lodash, args[0]) : func.apply(lodash, args); + var result = func.apply(lodash, args); if (this._chain) { result = new LoDash(result); result._chain = true; @@ -3061,7 +3071,7 @@ * @category Utilities * @param {Object} object The object to inspect. * @param {String} property The property to get the result of. - * @returns {Mixed} Returns the resolved. + * @returns {Mixed} Returns the resolved value. * @example * * var object = { @@ -3455,11 +3465,8 @@ LoDash.prototype[methodName] = function() { var value = this._wrapped; - if (arguments.length) { - func.apply(value, arguments); - } else { - func.call(value); - } + func.apply(value, arguments); + // IE compatibility mode and IE < 9 have buggy Array `shift()` and `splice()` // functions that fail to remove the last element, `value[0]`, of // array-like objects even though the `length` property is set to `0`. @@ -3482,7 +3489,7 @@ LoDash.prototype[methodName] = function() { var value = this._wrapped, - result = arguments.length ? func.apply(value, arguments) : func.call(value); + result = func.apply(value, arguments); if (this._chain) { result = new LoDash(result); From 3f7bccf2e6955bfa355287a5d1c9243a7afaaf2f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 9 Jun 2012 00:31:03 -0400 Subject: [PATCH 09/16] Update Backbone and Underscore submodules. Former-commit-id: 6f938216d0bb26347ce7fd42169f926e2ae04e0e --- vendor/backbone | 2 +- vendor/underscore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/backbone b/vendor/backbone index 85bd0b5132..7bcd6ad514 160000 --- a/vendor/backbone +++ b/vendor/backbone @@ -1 +1 @@ -Subproject commit 85bd0b5132e0da853eda114bd761d7961b80a146 +Subproject commit 7bcd6ad514f9d5682a2a5d5e892fc820d8ad1cce diff --git a/vendor/underscore b/vendor/underscore index 7229edc46e..23b35a21c7 160000 --- a/vendor/underscore +++ b/vendor/underscore @@ -1 +1 @@ -Subproject commit 7229edc46ef9a11c6bae2fe9b748022d3e56c19f +Subproject commit 23b35a21c7639a9840bdfcf6a9ab684d82bcd6db From 1e94b93ce648007f62a0753e55fe763a2233369e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 9 Jun 2012 03:10:57 -0400 Subject: [PATCH 10/16] Add Backbone build and correct dependencies for `_.bindAll`, `_.mixin`, and `_.sortBy`. Former-commit-id: 3d4413d6ab3b41471be6336d138a4b4bfa97fde7 --- README.md | 18 +++-- build.js | 201 ++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 160 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 7faccee33d..19821f2656 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,11 @@ Lo-Dash has been tested in at least Chrome 5-19, Firefox 1.5-13, 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. - + * Backbone builds, containing all methods required by Backbone, may be created by using the `backbone` modifier argument. +~~~ bash +node build backbone +~~~ + * Mobile builds, with IE bug fixes and method compilation removed, may be created by using the `mobile` modifier argument. ~~~ bash node build mobile ~~~ @@ -58,22 +61,25 @@ Custom builds may be created in three ways: Valid categories are *"arrays"*, *"chaining"*, *"collections"*, *"functions"*, *"objects"*, and *"utilities"*. ~~~ bash node build category=collections,functions -node build category="collections, functions" -node build mobile category=collections,functions ~~~ 2. Use the `include` argument to pass the names of the methods to include in the build. ~~~ bash node build include=each,filter,map node build include="each, filter, map" -node build mobile include=each,filter,map ~~~ 3. Use the `exclude` argument to pass the names of the methods to exclude from the build. ~~~ bash node build exclude=union,uniq,zip node build exclude="union, uniq, zip" -node build mobile exclude=union,uniq,zip +~~~ + +All arguments, except `include` and `exlcude`, may be combined. + +~~~ bash +node build backbone mobile category=functions include=pick,uniq +node build backbone mobile category=utilities exclude=first,last ~~~ Custom builds are saved to `lodash.custom.js` and `lodash.custom.min.js`. diff --git a/build.js b/build.js index 1a7773c3e1..d5f279e62c 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 mobile build */ - var isMobile = process.argv.indexOf('mobile') > -1; - /** Shortcut used to convert array-like objects to arrays */ var slice = [].slice; @@ -55,11 +52,56 @@ 'uniq': ['unique'] }; + /** Used to track Backbone's Lo-Dash dependencies */ + var backboneDependencies = [ + 'bind', + 'bindAll', + 'clone', + 'contains', + 'escape', + 'every', + 'extend', + 'filter', + 'find', + 'first', + 'forEach', + 'groupBy', + 'has', + 'indexOf', + 'initial', + 'invoke', + 'isArray', + 'isEmpty', + 'isEqual', + 'isFunction', + 'isObject', + 'isRegExp', + 'keys', + 'last', + 'lastIndexOf', + 'map', + 'max', + 'min', + 'mixin', + 'reduce', + 'reduceRight', + 'reject', + 'rest', + 'shuffle', + 'size', + 'some', + 'sortBy', + 'sortedIndex', + 'toArray', + 'uniqueId', + 'without' + ]; + /** Used to track function dependencies */ var dependencyMap = { 'after': [], 'bind': [], - 'bindAll': ['bind'], + 'bindAll': ['bind', 'functions'], 'chain': ['mixin'], 'clone': ['extend', 'isArray'], 'compact': [], @@ -112,7 +154,7 @@ 'max': [], 'memoize': [], 'min': [], - 'mixin': ['forEach'], + 'mixin': ['forEach', 'functions'], 'noConflict': [], 'once': [], 'partial': [], @@ -127,7 +169,7 @@ 'shuffle': [], 'size': ['keys'], 'some': ['createIterator', 'identity'], - 'sortBy': ['map', 'pluck'], + 'sortBy': [], 'sortedIndex': ['identity'], 'tap': [], 'template': ['escape'], @@ -143,40 +185,41 @@ 'zip': ['max', 'pluck'] }; - /** Names of all methods */ - var allMethods = Object.keys(dependencyMap); - - /** Names of methods to filter for the build */ - var filterMethods = allMethods; + /** Collections of method names */ + var excludeMethods, + includeMethods, + allMethods = Object.keys(dependencyMap); - /** Used to specify whether `filterMethods` is used for exclusion or inclusion */ + /** Used to specify whether filtering is for exclusion or inclusion */ var filterType = process.argv.reduce(function(result, value) { if (result) { return result; } - var pair = value.match(/^(category|exclude|include)=(.*)$/); + var pair = value.match(/^(exclude|include)=(.*)$/); if (!pair) { return result; } + // remove nonexistent method names + var methodNames = lodash.intersection(allMethods, pair[2].split(/, */).map(getRealName)); - result = pair[1]; - filterMethods = pair[2].split(/, */).map(getRealName); - - if (result == 'category') { - // resolve method names belonging to each category - filterMethods = filterMethods.reduce(function(result, category) { - return result.concat(allMethods.filter(function(funcName) { - return RegExp('@category ' + category + '\\b', 'i').test(matchFunction(source, funcName)); - })); - }, []); + if (pair[1] == 'exclude') { + excludeMethods = methodNames; + } else { + includeMethods = methodNames; } - else { - // remove nonexistent method names - filterMethods = lodash.intersection(allMethods, filterMethods); - } - return result; + // return `filterType` + return pair[1]; }, ''); + /** Flag used to specify a backbone build */ + var isBackbone = process.argv.indexOf('backbone') > -1; + + /** Flag used to specify a mobile build */ + var isMobile = process.argv.indexOf('mobile') > -1; + + /** Flag used to specify a custom build */ + var isCustom = filterType || isBackbone || isMobile; + /*--------------------------------------------------------------------------*/ /** @@ -201,7 +244,7 @@ // iterate over `dependencyMap`, adding the names of functions that // have `funcName` as a dependency return lodash.reduce(dependencyMap, function(result, dependencies, otherName) { - if (dependencies.indexOf(funcName) > -1) { + if (lodash.contains(dependencies, funcName)) { result.push(otherName); } return result; @@ -209,25 +252,26 @@ } /** - * Gets an array of dependencies for a function of the given `funcName`. + * Gets an array of dependencies for a given function name. If passed an array + * of dependencies it will return an array containing the given dependencies + * plus any additional detected sub-dependencies. * * @private - * @param {String} funcName The name of the function to query. + * @param {Array|String} funcName A single function name or array of + * dependencies to query. * @returns {Array} Returns an array of function dependencies. */ function getDependencies(funcName) { - var dependencies = dependencyMap[funcName], - result = []; - + var dependencies = Array.isArray(funcName) ? funcName : dependencyMap[funcName]; if (!dependencies) { - return result; + return []; } // recursively accumulate the dependencies of the `funcName` function, and // the dependencies of its dependencies, and so on. - return dependencies.reduce(function(result, otherName) { + return lodash.uniq(dependencies.reduce(function(result, otherName) { result.push.apply(result, getDependencies(otherName).concat(otherName)); return result; - }, result); + }, [])); } /** @@ -292,7 +336,7 @@ * @returns {String} Returns the modified source. */ function removeFromCreateIterator(source, refName) { - var snippet = matchFunction(source, 'createIterator'), + var snippet = matchFunction(source, 'createIterator').match(/Function\([\s\S]+$/)[0], modified = snippet.replace(RegExp('\\b' + refName + '\\b,? *', 'g'), ''); return source.replace(snippet, modified); @@ -389,30 +433,81 @@ /*--------------------------------------------------------------------------*/ + // Backbone build + if (isBackbone) { + // add any additional dependencies + backboneDependencies = getDependencies(backboneDependencies); + + if (filterType == 'exclude') { + // remove excluded methods from `backboneDependencies` + includeMethods = lodash.without.apply(lodash, [backboneDependencies].concat(excludeMethods)); + } + else if (filterType) { + // merge backbone dependencies into `includeMethods` + includeMethods = lodash.union(includeMethods, backboneDependencies); + } + else { + // include only the Backbone dependencies + includeMethods = backboneDependencies; + } + filterType = 'include'; + } + + /*--------------------------------------------------------------------------*/ + + // add category methods + process.argv.some(function(value) { + var categories = value.match(/^category=(.*)$/); + if (!categories) { + return false; + } + // resolve method names belonging to each category + var categoryMethods = categories.reduce(function(result, category) { + return result.concat(allMethods.filter(function(funcName) { + return RegExp('@category ' + category + '\\b', 'i').test(matchFunction(source, funcName)); + })); + }, []); + + if (filterType == 'exclude') { + // remove excluded methods from `categoryMethods` + includeMethods = lodash.without.apply(lodash, [categoryMethods].concat(excludeMethods)); + } + else if (filterType) { + // merge backbone dependencies into `includeMethods` + includeMethods = lodash.union(includeMethods, categoryMethods); + } + else { + // include only the Backbone dependencies + includeMethods = categoryMethods; + } + + filterType = 'include'; + return true; + }); + + /*--------------------------------------------------------------------------*/ + // custom build (function() { - // exit early if "category", "exclude", or "include" options aren't specified + // exit early if "exclude" or "include" options aren't specified if (!filterType) { return; } if (filterType == 'exclude') { - // remove methods that are named in `filterMethods` and their dependants - filterMethods.forEach(function(funcName) { + // remove methods that are named in `excludeMethods` and their dependants + excludeMethods.forEach(function(funcName) { getDependants(funcName).concat(funcName).forEach(function(otherName) { source = removeFunction(source, otherName); }); }); } else { - // add dependencies to `filterMethods` - filterMethods = lodash.uniq(filterMethods.reduce(function(result, funcName) { - result.push.apply(result, getDependencies(funcName).concat(funcName)); - return result; - }, [])); - - // remove methods that aren't named in `filterMethods` - lodash.each(dependencyMap, function(dependencies, otherName) { - if (filterMethods.indexOf(otherName) < 0) { + // add dependencies to `includeMethods` + includeMethods = getDependencies(includeMethods); + + // remove methods that aren't named in `includeMethods` + lodash.each(allMethods, function(otherName) { + if (!lodash.contains(includeMethods, otherName)) { source = removeFunction(source, otherName); } }); @@ -517,13 +612,13 @@ }())); } + /*--------------------------------------------------------------------------*/ + // remove pseudo private properties source = source.replace(/(?:(?:\s*\/\/.*)*\s*lodash\._[^=]+=.+\n)+/g, '\n'); - /*--------------------------------------------------------------------------*/ - // begin the minification process - if (filterType || isMobile) { + if (isCustom) { 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); From c5bceb8fc8990b1bde14a37a5457c5c718f1ad52 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 9 Jun 2012 03:11:36 -0400 Subject: [PATCH 11/16] Update documentation and minified build. Former-commit-id: edc6264f5721cbdb080c4f7772263848c125b3e2 --- doc/README.md | 118 +++++++++++++++++++++++++------------------------- lodash.min.js | 20 ++++----- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/doc/README.md b/doc/README.md index 9d32e844ac..f46b25fa13 100644 --- a/doc/README.md +++ b/doc/README.md @@ -147,7 +147,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3331 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3341 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -159,7 +159,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1782 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1792 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -187,7 +187,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1836 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1846 "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`. @@ -238,7 +238,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1907 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1917 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -270,7 +270,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3283 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3293 "View in source") [Ⓣ][1] Wraps the value in a `lodash` chainable object. @@ -304,7 +304,7 @@ var youngest = _.chain(stooges) ### `_.clone(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2243 "View in source") [Ⓣ][1] Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned. @@ -352,9 +352,9 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1939 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1949 "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()))`. +Creates a new function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. #### Arguments 1. `[func1, func2, ...]` *(Function)*: Functions to compose. @@ -404,7 +404,7 @@ _.contains([1, 2, 3], 3); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1972 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1982 "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. @@ -430,7 +430,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, defaults1, defaults2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2256 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2266 "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. @@ -456,7 +456,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2037 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2047 "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. @@ -481,7 +481,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2017 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2027 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments are passed to `func` when it is invoked. @@ -533,7 +533,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2974 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2984 "View in source") [Ⓣ][1] Escapes a string for inclusion in HTML, replacing `&`, `<`, `"`, and `'` characters. @@ -583,7 +583,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2275 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2285 "View in source") [Ⓣ][1] Copies enumerable properties from the source objects to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -743,7 +743,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.forIn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2314 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. @@ -779,7 +779,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2327 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2337 "View in source") [Ⓣ][1] Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. @@ -807,7 +807,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2344 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2354 "View in source") [Ⓣ][1] Produces a sorted array of the enumerable properties, own and inherited, of `object` that have function values. @@ -863,7 +863,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2377 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -888,7 +888,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3003 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -1021,7 +1021,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2387 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2397 "View in source") [Ⓣ][1] Checks if a `value` is an `arguments` object. @@ -1048,7 +1048,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2413 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2423 "View in source") [Ⓣ][1] Checks if a `value` is an array. @@ -1075,7 +1075,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2430 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2440 "View in source") [Ⓣ][1] Checks if a `value` is a boolean *(`true` or `false`)* value. @@ -1099,7 +1099,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2447 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2457 "View in source") [Ⓣ][1] Checks if a `value` is a date. @@ -1123,7 +1123,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2464 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2474 "View in source") [Ⓣ][1] Checks if a `value` is a DOM element. @@ -1147,7 +1147,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2485 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2495 "View in source") [Ⓣ][1] Checks if a `value` is empty. Arrays or strings with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -1174,7 +1174,7 @@ _.isEmpty({}); ### `_.isEqual(a, b [, stack])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2519 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2529 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -1206,7 +1206,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2681 "View in source") [Ⓣ][1] Checks if a `value` is a finite number. @@ -1236,7 +1236,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2688 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2698 "View in source") [Ⓣ][1] Checks if a `value` is a function. @@ -1260,7 +1260,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2739 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2749 "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. @@ -1293,7 +1293,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2761 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2771 "View in source") [Ⓣ][1] Checks if a `value` is `null`. @@ -1320,7 +1320,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2778 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2788 "View in source") [Ⓣ][1] Checks if a `value` is a number. @@ -1344,7 +1344,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2709 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2719 "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('')`) @@ -1371,7 +1371,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2795 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2805 "View in source") [Ⓣ][1] Checks if a `value` is a regular expression. @@ -1395,7 +1395,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2812 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2822 "View in source") [Ⓣ][1] Checks if a `value` is a string. @@ -1419,7 +1419,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2829 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2839 "View in source") [Ⓣ][1] Checks if a `value` is `undefined`. @@ -1443,7 +1443,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2846 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2856 "View in source") [Ⓣ][1] Produces an array of object`'s own enumerable property names. @@ -1583,7 +1583,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2070 "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. @@ -1635,7 +1635,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3019 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3029 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1665,7 +1665,7 @@ _('larry').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3060 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1685,7 +1685,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2086 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2096 "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. @@ -1711,7 +1711,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2119 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2129 "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. @@ -1738,7 +1738,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2868 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2878 "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. @@ -1939,7 +1939,7 @@ _.rest([3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3090 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. @@ -1948,7 +1948,7 @@ Resolves the value of `property` on `object`. If `property` is a function it wil 2. `property` *(String)*: The property to get the result of. #### Returns -*(Mixed)*: Returns the resolved. +*(Mixed)*: Returns the resolved value. #### Example ~~~ js @@ -1998,7 +1998,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2906 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2916 "View in source") [Ⓣ][1] Gets the size of `value` by returning `value.length` if `value` is a string or array, or the number of own enumerable properties if `value` is an object. @@ -2086,7 +2086,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1583 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1593 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with `1` argument; *(value)*. @@ -2127,7 +2127,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) { ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2934 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2944 "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. @@ -2157,7 +2157,7 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3139 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3149 "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. @@ -2216,7 +2216,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' }); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2155 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2165 "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. @@ -2241,7 +2241,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3226 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3236 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*. @@ -2291,7 +2291,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1620 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1630 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays. @@ -2315,7 +2315,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1665 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1675 "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 bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -2351,7 +2351,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3253 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3263 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2375,7 +2375,7 @@ _.uniqueId('contact_'); ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2962 "View in source") [Ⓣ][1] Produces an array of `object`'s own enumerable property values. @@ -2399,7 +2399,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1724 "View in source") [Ⓣ][1] Produces a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2424,7 +2424,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(func, wrapper [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2207 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2217 "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. @@ -2454,7 +2454,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1747 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1757 "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. @@ -2485,7 +2485,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3301 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3311 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2506,7 +2506,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3328 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. diff --git a/lodash.min.js b/lodash.min.js index 40efffe218..1d6711d5ea 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -9,10 +9,10 @@ f+",k)",a.l=f,a.p=F,a.r=a.r!==i,a.f||(a.f="if(!"+o+")return r");if("n"==o||!t.j) (e,n,r){return e?nt.call(e,n==t||r?1:n):[]}function T(e,t,n,r){if(!e)return 0;var i,s=0,o=e.length;if(n)for(t=n.call(r,t);s>>1,n.call(r,e[i])>>1,e[i]w(a,r))a.push(r),s.push(e[o]);return s}function C(e,t){function n(){var u=arguments,a=t;return s||(e=t[i]), o.length&&(u=u.length?Z.apply(o,u):o),this instanceof n?(p.prototype=e.prototype,a=new p,u=e.apply(a,u),U[typeof u]&&u!==r?u:a):e.apply(a,u)}var i,s=rt.call(e)==$;if(s){if(it)return it.call.apply(it,arguments)}else i=t,t=e;var o=nt.call(arguments,2);return n}function k(e,r,s){s||(s=[]);if(e===r)return 0!==e||1/e==1/r;if(e==t||r==t)return e===r;e._chain&&(e=e._wrapped),r._chain&&(r=r._wrapped);if(e.isEqual&&rt.call(e.isEqual)==$)return e.isEqual(r);if(r.isEqual&&rt.call(r.isEqual)==$)return r.isEqual (e);var o=rt.call(e);if(o!=rt.call(r))return i;switch(o){case Q:return e==""+r;case J:return e!=+e?r!=+r:0==e?1/e==1/r:e==+r;case X:case V:return+e==+r;case K:return e.source==r.source&&e.global==r.global&&e.multiline==r.multiline&&e.ignoreCase==r.ignoreCase}if("object"!=typeof e||"object"!=typeof r)return i;for(var u=s.length;u--;)if(s[u]==e)return n;var u=-1,a=n,f=0;s.push(e);if(o==W){if(f=e.length,a=f==r.length)for(;f--&&(a=k(e[f],r[f],s)););}else{if("constructor"in e!="constructor"in r||e.constructor!= -r.constructor)return i;for(var l in e)if(et.call(e,l)&&(f++,!(a=et.call(r,l)&&k(e[l],r[l],s))))break;if(a){for(l in r)if(et.call(r,l)&&!(f--))break;a=!f}if(a&&M)for(;7>++u&&(l=F[u],!et.call(e,l)||!!(a=et.call(r,l)&&k(e[l],r[l],s))););}return s.pop(),a}function L(e){return e}function A(e){wt(Nt(e),function(t){var r=o[t]=e[t];u.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&tt.apply(e,arguments),e=1==e.length?r.call(o,e[0]):r.apply(o,e),this._chain&&(e=new u(e),e._chain=n),e -}})}var n=!0,r=null,i=!1,O="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(e=global),exports),M=!{valueOf:0}.propertyIsEnumerable("valueOf"),_=0,D=e._,P=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),H=/__token__(\d+)/g,B=/[&<"']/g,j=/['\n\r\t\u2028\u2029\\]/g,F="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),I="__token__",q=[],R= -{"&":"&","<":"<",'"':""","'":"'"},U={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},W="[object Array]",X="[object Boolean]",V="[object Date]",$="[object Function]",J="[object Number]",K="[object RegExp]",Q="[object String]",G=Array.prototype,Y=Object.prototype,Z=G.concat,et=Y.hasOwnProperty,tt=G.push,nt=G.slice,rt=Y.toString,it=P.test(it=nt.bind)&&/\n|Opera/.test(it+rt.call(e.opera -))&&it,st=P.test(st=Array.isArray)&&st,ot=e.isFinite,ut=P.test(ut=Object.keys)&&ut,at=e.clearTimeout,ft=e.setTimeout;o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var lt=Function("obj","var __p;with(obj){__p='var k,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;k=-1;';if(o){__p+='if(m===m>>>0){'};__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&&k==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var f='+l+'.constructor;';for(var k=0;k<7;k++){__p+='k=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(f&&f.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" +r.constructor)return i;for(var l in e)if(et.call(e,l)&&(f++,!(a=et.call(r,l)&&k(e[l],r[l],s))))break;if(a){for(l in r)if(et.call(r,l)&&!(f--))break;a=!f}if(a&&M)for(;7>++u&&(l=F[u],!et.call(e,l)||!!(a=et.call(r,l)&&k(e[l],r[l],s))););}return s.pop(),a}function L(e){return e}function A(e){wt(Nt(e),function(t){var r=o[t]=e[t];u.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&tt.apply(e,arguments),e=r.apply(o,e),this._chain&&(e=new u(e),e._chain=n),e}})}var n=!0,r=null,i=!1,O="object"==typeof +exports&&exports&&("object"==typeof global&&global&&global==global.global&&(e=global),exports),M=!{valueOf:0}.propertyIsEnumerable("valueOf"),_=0,D=e._,P=RegExp("^"+({}.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),H=/__token__(\d+)/g,B=/[&<"']/g,j=/['\n\r\t\u2028\u2029\\]/g,F="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),I="__token__",q=[],R={"&":"&","<":"<",'"':""","'":"'" +},U={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},W="[object Array]",X="[object Boolean]",V="[object Date]",$="[object Function]",J="[object Number]",K="[object RegExp]",Q="[object String]",G=Array.prototype,Y=Object.prototype,Z=G.concat,et=Y.hasOwnProperty,tt=G.push,nt=G.slice,rt=Y.toString,it=P.test(it=nt.bind)&&/\n|Opera/.test(it+rt.call(e.opera))&&it,st=P.test(st=Array.isArray)&&st,ot=e.isFinite +,ut=P.test(ut=Object.keys)&&ut,at=e.clearTimeout,ft=e.setTimeout;o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var lt=Function("obj","var __p;with(obj){__p='var k,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;k=-1;';if(o){__p+='if(m===m>>>0){'};__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&&k==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var f='+l+'.constructor;';for(var k=0;k<7;k++){__p+='k=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(f&&f.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" ),ct={a:"e,c,x",k:"e",q:"if(!c){c=j}else if(x){c=l(c,x)}",j:"c(e[k],k,e)"},ht={k:"z",j:"if(!c(e[k],k,e))return!r"},pt={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ue?t():function(){if(1>--e)return t.apply(this,arguments)}},o.bind=C,o.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=Nt(e));for( @@ -24,9 +24,9 @@ nt.call(arguments,1);++rw(t,n)&&yt(s,function(e){return-1n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},o.map=Et,o.max=E,o.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},o.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s arguments.length&&(t=e||0,e=0);for(var r=-1,i=Math.max(Math.ceil((t-e)/n),0),s=Array(i);++ri?1:0}),"b")},o.sortedIndex=T,o.tap=function(e,t){return t(e),e},o.template=function(e,t,n){n||(n={});var i;i=o.templateSettings;var s=n.escape,u=n.evaluate,a=n.interpolate,n=n.variable;return s==r&&(s=i.escape),u==r&&(u=i.evaluate),a==r&&(a=i.interpolate),s&&(e=e.replace(s,d)),a&&(e=e. -replace(a,v)),u&&(e=e.replace(u,m)),e="__p='"+e.replace(j,l).replace(H,f)+"';",q.length=0,n||(n=i.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+e+"return __p}",i=Function("_","return "+e)(o),t?i(t):(i.source=e,i)},o.throttle=function(e,n){function r(){a=new Date,u=t,e.apply(o,i)}var i,s,o,u,a=0;return function(){var t=new Date,f=n-(t-a);return i=arguments,o=this,0>=f?(a=t,s=e.apply(o,i)):u||(u=ft(r,f)),s -}},o.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?nt.call(e):Lt(e)},o.union=function(){for(var e=-1,t=[],n=Z.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},o.uniq=N,o.uniqueId=function(e){var t=_++;return e?e+t:t},o.values=Lt,o.without=function(e){var t=[];if(!e)return t;for(var n=nt.call(arguments,1),r=-1,i=e.length;++rw(n,e[r])&&t.push(e[r]);return t},o.wrap=function(e,t){return function(){var n=[e];return arguments.length&&tt.apply(n,arguments),t.apply(this,n)}},o.zip=function(e){if(!e)return[];for(var t=-1,n=E(S(arguments,"length")),r=Array(n);++ti?1:0});s--;)o[s]=o[s].b;return o},o.sortedIndex=T,o.tap=function(e,t){return t(e),e},o.template=function(e,t,n){n||(n={});var i;i=o.templateSettings;var s=n.escape,u=n.evaluate,a=n.interpolate,n=n.variable;return s==r&&(s=i.escape),u==r&&(u=i.evaluate),a==r&&(a=i +.interpolate),s&&(e=e.replace(s,d)),a&&(e=e.replace(a,v)),u&&(e=e.replace(u,m)),e="__p='"+e.replace(j,l).replace(H,f)+"';",q.length=0,n||(n=i.variable,e="with("+n+"||{}){"+e+"}"),e="function("+n+"){var __p,__t,__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+e+"return __p}",i=Function("_","return "+e)(o),t?i(t):(i.source=e,i)},o.throttle=function(e,n){function r(){a=new Date,u=t,e.apply(o,i)}var i,s,o,u,a=0;return function(){var t=new Date,f=n-(t-a);return i=arguments,o=this +,0>=f?(a=t,s=e.apply(o,i)):u||(u=ft(r,f)),s}},o.times=function(e,t,n){var r=-1;if(n)for(;++r>>0?nt.call(e):Lt(e)},o.union=function(){for(var e=-1,t=[],n=Z.apply(t,arguments),r=n.length;++ew(t,n[e])&&t.push(n[e]);return t},o.uniq=N,o.uniqueId=function(e){var t=_++;return e?e+t:t},o.values=Lt,o.without=function(e){var t=[];if(!e)return t;for(var n= +nt.call(arguments,1),r=-1,i=e.length;++rw(n,e[r])&&t.push(e[r]);return t},o.wrap=function(e,t){return function(){var n=[e];return arguments.length&&tt.apply(n,arguments),t.apply(this,n)}},o.zip=function(e){if(!e)return[];for(var t=-1,n=E(S(arguments,"length")),r=Array(n);++t Date: Sat, 9 Jun 2012 03:17:30 -0400 Subject: [PATCH 12/16] Cleanup README.md. Former-commit-id: 1cc58476c5737624b97801aabc0dc7368c43c0d3 --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 19821f2656..4d5d05aa42 100644 --- a/README.md +++ b/README.md @@ -46,11 +46,12 @@ Lo-Dash has been tested in at least Chrome 5-19, Firefox 1.5-13, 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. - * Backbone builds, containing all methods required by Backbone, may be created by using the `backbone` modifier argument. + * Backbone builds, containing all methods required by Backbone, may be created using the `backbone` modifier argument. ~~~ bash node build backbone ~~~ - * Mobile builds, with IE bug fixes and method compilation removed, may be created by using the `mobile` modifier argument. + + * Mobile builds, with IE bug fixes and method compilation removed, may be created using the `mobile` modifier argument. ~~~ bash node build mobile ~~~ @@ -61,15 +62,16 @@ Custom builds may be created in three ways: Valid categories are *"arrays"*, *"chaining"*, *"collections"*, *"functions"*, *"objects"*, and *"utilities"*. ~~~ bash node build category=collections,functions +node build category="collections, functions" ~~~ - 2. Use the `include` argument to pass the names of the methods to include in the build. + 2. Use the `include` argument to pass the names of methods to include in the build. ~~~ bash node build include=each,filter,map node build include="each, filter, map" ~~~ - 3. Use the `exclude` argument to pass the names of the methods to exclude from the build. + 3. Use the `exclude` argument to pass the names of methods to exclude from the build. ~~~ bash node build exclude=union,uniq,zip node build exclude="union, uniq, zip" From 2da05d88a0db9a80029265ee164555c43751c760 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 10 Jun 2012 12:54:14 -0400 Subject: [PATCH 13/16] Add another code example to `_.invoke` documentation. Former-commit-id: 0bea74a470771ebc5cf2110243b38db3698cde52 --- doc/README.md | 191 +++++++++++++++++++++++++------------------------- lodash.js | 5 +- 2 files changed, 101 insertions(+), 95 deletions(-) diff --git a/doc/README.md b/doc/README.md index f46b25fa13..c5c4480894 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v0.3.0 +# Lo-Dash v0.3.1 @@ -129,7 +129,7 @@ ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L134 "View in source") [Ⓣ][1] The `lodash` function. @@ -147,7 +147,7 @@ The `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3341 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3344 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -159,7 +159,7 @@ The `lodash` function. ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1795 "View in source") [Ⓣ][1] Creates a new function that is restricted to executing only after it is called `n` times. @@ -187,7 +187,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1846 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1849 "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`. @@ -238,7 +238,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1917 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1920 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -270,7 +270,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3296 "View in source") [Ⓣ][1] Wraps the value in a `lodash` chainable object. @@ -304,7 +304,7 @@ var youngest = _.chain(stooges) ### `_.clone(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2243 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2246 "View in source") [Ⓣ][1] Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned. @@ -328,7 +328,7 @@ _.clone({ 'name': 'moe' }); ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L892 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L892 "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. @@ -352,7 +352,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1949 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1952 "View in source") [Ⓣ][1] Creates a new function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. @@ -379,7 +379,7 @@ welcome('moe'); ### `_.contains(collection, target)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L578 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L578 "View in source") [Ⓣ][1] Checks if a given `target` value is present in a `collection` using strict equality for comparisons, i.e. `===`. @@ -404,7 +404,7 @@ _.contains([1, 2, 3], 3); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1982 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1985 "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. @@ -430,7 +430,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defaults(object [, defaults1, defaults2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2266 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2269 "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. @@ -456,7 +456,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2050 "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. @@ -481,7 +481,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2027 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2030 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments are passed to `func` when it is invoked. @@ -508,7 +508,7 @@ _.delay(log, 1000, 'logged later'); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L924 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L924 "View in source") [Ⓣ][1] Produces a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -533,7 +533,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2984 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2987 "View in source") [Ⓣ][1] Escapes a string for inclusion in HTML, replacing `&`, `<`, `"`, and `'` characters. @@ -557,7 +557,7 @@ _.escape('Curly, Larry & Moe'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L603 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L603 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -583,7 +583,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.extend(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2285 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2288 "View in source") [Ⓣ][1] Copies enumerable properties from the source objects to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -608,7 +608,7 @@ _.extend({ 'name': 'moe' }, { 'age': 40 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L624 "View in source") [Ⓣ][1] Examines each value in a `collection`, returning an array of all values the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -634,7 +634,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/v0.3.0/lodash.js#L646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L646 "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 bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -660,7 +660,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/v0.3.0/lodash.js#L960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L960 "View in source") [Ⓣ][1] Gets the first value of the `array`. Pass `n` to return the first `n` values of the `array`. @@ -686,7 +686,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L984 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L984 "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. @@ -714,7 +714,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.forEach(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L673 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L673 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each value in the `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -743,7 +743,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.forIn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2317 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. @@ -779,7 +779,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2340 "View in source") [Ⓣ][1] Iterates over `object`'s own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, key, object)*. @@ -807,7 +807,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2354 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2357 "View in source") [Ⓣ][1] Produces a sorted array of the enumerable properties, own and inherited, of `object` that have function values. @@ -831,7 +831,7 @@ _.functions(_); ### `_.groupBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1029 "View in source") [Ⓣ][1] Splits `array` into sets, grouped by the result of running each value through `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to group by. @@ -863,7 +863,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2377 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2380 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -888,7 +888,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3003 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3006 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. @@ -913,7 +913,7 @@ moe === _.identity(moe); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1075 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1075 "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. @@ -945,7 +945,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1115 "View in source") [Ⓣ][1] Gets all but the last value of `array`. Pass `n` to exclude the last `n` values from the result. @@ -971,7 +971,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1136 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1136 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays. @@ -995,7 +995,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.invoke(array, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1175 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1178 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element of `array`. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element of `array`. @@ -1011,6 +1011,9 @@ Invokes the method named by `methodName` on each element of `array`. Additional ~~~ js _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); // => [[1, 5, 7], [1, 2, 3]] + +_.invoke([123, 456], String.prototype.split, ''); +// => [['1', '2', '3'], ['4', '5', '6']] ~~~ * * * @@ -1021,7 +1024,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2397 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2400 "View in source") [Ⓣ][1] Checks if a `value` is an `arguments` object. @@ -1048,7 +1051,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2423 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2426 "View in source") [Ⓣ][1] Checks if a `value` is an array. @@ -1075,7 +1078,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2440 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2443 "View in source") [Ⓣ][1] Checks if a `value` is a boolean *(`true` or `false`)* value. @@ -1099,7 +1102,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2457 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2460 "View in source") [Ⓣ][1] Checks if a `value` is a date. @@ -1123,7 +1126,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2474 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2477 "View in source") [Ⓣ][1] Checks if a `value` is a DOM element. @@ -1147,7 +1150,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2495 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2498 "View in source") [Ⓣ][1] Checks if a `value` is empty. Arrays or strings with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -1174,7 +1177,7 @@ _.isEmpty({}); ### `_.isEqual(a, b [, stack])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2529 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2532 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -1206,7 +1209,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2681 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2684 "View in source") [Ⓣ][1] Checks if a `value` is a finite number. @@ -1236,7 +1239,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2698 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2701 "View in source") [Ⓣ][1] Checks if a `value` is a function. @@ -1260,7 +1263,7 @@ _.isFunction(''.concat); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2749 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2752 "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. @@ -1293,7 +1296,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2774 "View in source") [Ⓣ][1] Checks if a `value` is `null`. @@ -1320,7 +1323,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2788 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2791 "View in source") [Ⓣ][1] Checks if a `value` is a number. @@ -1344,7 +1347,7 @@ _.isNumber(8.4 * 5; ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2719 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2722 "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('')`) @@ -1371,7 +1374,7 @@ _.isObject(1); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2805 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2808 "View in source") [Ⓣ][1] Checks if a `value` is a regular expression. @@ -1395,7 +1398,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2822 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2825 "View in source") [Ⓣ][1] Checks if a `value` is a string. @@ -1419,7 +1422,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2842 "View in source") [Ⓣ][1] Checks if a `value` is `undefined`. @@ -1443,7 +1446,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2859 "View in source") [Ⓣ][1] Produces an array of object`'s own enumerable property names. @@ -1467,7 +1470,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.last(array [, n, guard])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1209 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1212 "View in source") [Ⓣ][1] Gets the last value of the `array`. Pass `n` to return the lasy `n` values of the `array`. @@ -1493,7 +1496,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1235 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1238 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. @@ -1522,7 +1525,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L697 "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 `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -1551,7 +1554,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1275 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1278 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1583,7 +1586,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2070 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2073 "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. @@ -1609,7 +1612,7 @@ var fibonacci = _.memoize(function(n) { ### `_.min(array [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1325 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1328 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -1635,7 +1638,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3032 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -1665,7 +1668,7 @@ _('larry').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3063 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -1685,7 +1688,7 @@ var lodash = _.noConflict(); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2096 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2099 "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. @@ -1711,7 +1714,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2129 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2132 "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. @@ -1738,7 +1741,7 @@ hi('moe'); ### `_.pick(object [, prop1, prop2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2878 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2881 "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. @@ -1763,7 +1766,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); ### `_.pluck(array, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1377 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1380 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in `array`. @@ -1794,7 +1797,7 @@ _.pluck(stooges, 'name'); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1423 "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. @@ -1832,7 +1835,7 @@ _.range(0); ### `_.reduce(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L731 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L731 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*. @@ -1859,7 +1862,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L768 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L768 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1887,7 +1890,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L819 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1913,7 +1916,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/v0.3.0/lodash.js#L1456 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1459 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -1939,7 +1942,7 @@ _.rest([3, 2, 1]); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3093 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. @@ -1974,7 +1977,7 @@ _.result(object, 'stuff'); ### `_.shuffle(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1477 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1480 "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. @@ -1998,7 +2001,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2916 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2919 "View in source") [Ⓣ][1] Gets the size of `value` by returning `value.length` if `value` is a string or array, or the number of own enumerable properties if `value` is an object. @@ -2028,7 +2031,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L843 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L843 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. @@ -2054,7 +2057,7 @@ _.some([null, 0, 'yes', false]); ### `_.sortBy(array, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1519 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1522 "View in source") [Ⓣ][1] Produces a new sorted array, ranked in ascending order by the results of running each element of `array` through `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -2086,7 +2089,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1596 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with `1` argument; *(value)*. @@ -2127,7 +2130,7 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) { ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2944 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2947 "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. @@ -2157,9 +2160,9 @@ _.chain([1,2,3,200]) ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3152 "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. +A micro-templating method, similar to John Resig's implementation. Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. #### Arguments 1. `text` *(String)*: The template text. @@ -2216,7 +2219,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' }); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2165 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2168 "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. @@ -2241,7 +2244,7 @@ jQuery(window).on('scroll', throttled); ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3236 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3239 "View in source") [Ⓣ][1] Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*. @@ -2267,7 +2270,7 @@ _.times(3, function() { this.grantWish(); }, genie); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L862 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L862 "View in source") [Ⓣ][1] Converts the `collection`, into an array. Useful for converting the `arguments` object. @@ -2291,7 +2294,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments` ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1630 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1633 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays. @@ -2315,7 +2318,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1675 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1678 "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 bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*. @@ -2351,7 +2354,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3263 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3266 "View in source") [Ⓣ][1] Generates a unique id. If `prefix` is passed, the id will be appended to it. @@ -2375,7 +2378,7 @@ _.uniqueId('contact_'); ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2962 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2965 "View in source") [Ⓣ][1] Produces an array of `object`'s own enumerable property values. @@ -2399,7 +2402,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1727 "View in source") [Ⓣ][1] Produces a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -2424,7 +2427,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.wrap(func, wrapper [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L2217 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L2220 "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. @@ -2454,7 +2457,7 @@ hello(); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L1757 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L1760 "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. @@ -2485,7 +2488,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3311 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3314 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2506,7 +2509,7 @@ _([1, 2, 3]).value(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L3328 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L3331 "View in source") [Ⓣ][1] Extracts the value from a wrapped chainable object. @@ -2534,7 +2537,7 @@ _([1, 2, 3]).value(); ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L162 "View in source") [Ⓣ][1] *(Object)*: By default, Lo-Dash uses ERB-style template delimiters, change the following template settings to use alternative delimiters. @@ -2546,7 +2549,7 @@ _([1, 2, 3]).value(); ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L171 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -2558,7 +2561,7 @@ _([1, 2, 3]).value(); ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L180 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L180 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -2570,7 +2573,7 @@ _([1, 2, 3]).value(); ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L189 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L189 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -2582,7 +2585,7 @@ _([1, 2, 3]).value(); ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js#L198 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js#L198 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index 98d8931319..b0f305075c 100644 --- a/lodash.js +++ b/lodash.js @@ -1171,6 +1171,9 @@ * * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); * // => [[1, 5, 7], [1, 2, 3]] + * + * _.invoke([123, 456], String.prototype.split, ''); + * // => [['1', '2', '3'], ['4', '5', '6']] */ function invoke(array, methodName) { var result = []; @@ -3096,7 +3099,7 @@ } /** - * A JavaScript micro-templating method, similar to John Resig's implementation. + * A micro-templating method, similar to John Resig's implementation. * Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and * correctly escapes quotes within interpolated code. * From 250a0ab5eb24e0d24c982d53b58b8788d7af57fb Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 10 Jun 2012 13:46:45 -0400 Subject: [PATCH 14/16] Add `_.shuffle` benchmark. Former-commit-id: 13a0a7392108571d4ebced5e6e6ff66048091983 --- perf/perf.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/perf/perf.js b/perf/perf.js index 68bff8b283..75a1696b19 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -479,6 +479,18 @@ /*--------------------------------------------------------------------------*/ + suites.push( + Benchmark.Suite('shuffle') + .add('Lo-Dash', function() { + lodash.shuffle(numbers); + }) + .add('Underscore', function() { + _.shuffle(numbers); + }) + ); + + /*--------------------------------------------------------------------------*/ + suites.push( Benchmark.Suite('sortBy callback') .add('Lo-Dash', function() { From 94e8af4d936febc96a40178ddd48459ce195ff2d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 10 Jun 2012 23:58:43 -0400 Subject: [PATCH 15/16] Update submodules. Former-commit-id: 0658ae9b9e49c468f839738f34c9f6361b90897e --- vendor/benchmark.js | 2 +- vendor/qunit | 2 +- vendor/uglifyjs | 2 +- vendor/underscore | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vendor/benchmark.js b/vendor/benchmark.js index c304a20cd6..7e889ce6ad 160000 --- a/vendor/benchmark.js +++ b/vendor/benchmark.js @@ -1 +1 @@ -Subproject commit c304a20cd63b12d3439f6a60dc72192d7f626ed2 +Subproject commit 7e889ce6ad3b130e6f82810c3a5fbe378717f556 diff --git a/vendor/qunit b/vendor/qunit index 3f5e8b2123..0d596a809d 160000 --- a/vendor/qunit +++ b/vendor/qunit @@ -1 +1 @@ -Subproject commit 3f5e8b2123c66d4c9ab83b76f3785e799cd9b5d5 +Subproject commit 0d596a809dea881f05b3abd53c3fd70dcf876c69 diff --git a/vendor/uglifyjs b/vendor/uglifyjs index e87718e2d1..a3fcb0d2aa 160000 --- a/vendor/uglifyjs +++ b/vendor/uglifyjs @@ -1 +1 @@ -Subproject commit e87718e2d1835a3836d9e6e06f0f6e7e6458a298 +Subproject commit a3fcb0d2aa8b3b78193dbe2b59994a5b65d552a4 diff --git a/vendor/underscore b/vendor/underscore index 23b35a21c7..91a841a0a9 160000 --- a/vendor/underscore +++ b/vendor/underscore @@ -1 +1 @@ -Subproject commit 23b35a21c7639a9840bdfcf6a9ab684d82bcd6db +Subproject commit 91a841a0a9ee9c75c9f993b079133528c6465df0 From 1e2ef542e4cda52e0692c67005185a5daf51e19a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 11 Jun 2012 00:08:41 -0400 Subject: [PATCH 16/16] Bump to v0.3.1. Former-commit-id: 2e1e3b7e47b1f98d2ca20a89a4570a0b958d4323 --- README.md | 42 +++++++++++++++++++++++++----------------- doc/parse.php | 4 ++-- lodash.js | 4 ++-- lodash.min.js | 4 ++-- package.json | 2 +- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 4d5d05aa42..177bc7df4e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v0.3.0 +# Lo-Dash v0.3.1 A drop-in replacement for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), that delivers [performance improvements](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#closed-underscorejs-issues), and [additional features](https://github.com/bestiejs/lodash#features). @@ -6,8 +6,8 @@ Lo-Dash’s performance is gained by avoiding slower native methods, instead opt ## Download - * [Development source](https://raw.github.com/bestiejs/lodash/v0.3.0/lodash.js) - * [Production source](https://raw.github.com/bestiejs/lodash/v0.3.0/lodash.min.js) + * [Development source](https://raw.github.com/bestiejs/lodash/v0.3.1/lodash.js) + * [Production source](https://raw.github.com/bestiejs/lodash/v0.3.1/lodash.min.js) * For optimal performance, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need ## Dive in @@ -25,7 +25,7 @@ For more information check out these screencasts over Lo-Dash: ## Features - * AMD loader support (RequireJS, curl.js, etc.) + * AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.) * [_.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 @@ -150,20 +150,21 @@ git submodule update --init ## Closed Underscore.js issues - * Allow iteration of objects with a `length` property [[#148](https://github.com/documentcloud/underscore/issues/148), [#154](https://github.com/documentcloud/underscore/issues/154), [#252](https://github.com/documentcloud/underscore/issues/252), [#448](https://github.com/documentcloud/underscore/issues/448), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L266-272)] - * Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L237-243), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L533-542), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L661-664)] - * Ensure `_(...)` returns passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L106-109)] - * Ensure `_.groupBy` adds values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L317-324)] - * Ensure `_.sortedIndex` supports arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L586-595)] - * Ensure `_.throttle` works when called in tight loops [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L629-639)] - * Fix Firefox, IE, Opera, and Safari object iteration bugs [[#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L175-187), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L277-302), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L379-390), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L398-400), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L418-438), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L554-556)] + * Allow iteration of objects with a `length` property [[#148](https://github.com/documentcloud/underscore/issues/148), [#154](https://github.com/documentcloud/underscore/issues/154), [#252](https://github.com/documentcloud/underscore/issues/252), [#448](https://github.com/documentcloud/underscore/issues/448), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L266-272)] + * Ensure "Arrays" category methods allow falsey `array` arguments [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L714-748)] + * Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L237-243), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L533-542), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L661-664)] + * Ensure `_(...)` returns passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L106-109)] + * Ensure `_.groupBy` adds values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L317-324)] + * Ensure `_.sortedIndex` supports arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L586-595)] + * Ensure `_.throttle` works when called in tight loops [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L629-639)] + * Fix Firefox, IE, Opera, and Safari object iteration bugs [[#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L175-187), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L277-302), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L379-390), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L398-400), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L418-438), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L554-556)] * Handle arrays with `undefined` values correctly in IE < 9 [[#601](https://github.com/documentcloud/underscore/issues/601)] - * Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L88-94)] - * Register as AMD module, but still export to global [[#431](https://github.com/documentcloud/underscore/pull/431), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L72-86)] - * `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L232-235)] - * `_isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L408-410)] - * `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L521-531)] - * `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/c07e1567a7a12cff2c5ee6cda81306c8bcf126f0/test/test.js#L550-552)] + * Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L88-94)] + * Register as AMD module, but still export to global [[#431](https://github.com/documentcloud/underscore/pull/431), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L72-86)] + * `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L232-235)] + * `_isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L408-410)] + * `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L521-531)] + * `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/801e8a5b3a963157fceaad15075690f59c22de9c/test/test.js#L550-552)] ## Optimized methods (50+) @@ -223,6 +224,13 @@ git submodule update --init ## Changelog +### v0.3.1 + + * Added `backbone` build option + * Ensured "Arrays" category methods allow falsey `array` arguments + * Removed `_.isArguments` fallback from the `mobile` build + * Simplified `_.pluck`, `_.values` and `_(...)` method wrappers + ### v0.3.0 * Added `category` build option diff --git a/doc/parse.php b/doc/parse.php index 5dd4ff34bc..1cc10f05dd 100644 --- a/doc/parse.php +++ b/doc/parse.php @@ -21,8 +21,8 @@ // generate Markdown $markdown = docdown(array( 'path' => '../' . $file, - 'title' => 'Lo-Dash v0.3.0', - 'url' => 'https://github.com/bestiejs/lodash/blob/v0.3.0/lodash.js' + 'title' => 'Lo-Dash v0.3.1', + 'url' => 'https://github.com/bestiejs/lodash/blob/v0.3.1/lodash.js' )); // save to a .md file diff --git a/lodash.js b/lodash.js index b0f305075c..673a59bf67 100644 --- a/lodash.js +++ b/lodash.js @@ -1,5 +1,5 @@ /*! - * Lo-Dash v0.3.0 + * Lo-Dash v0.3.1 * Copyright 2012 John-David Dalton * Based on Underscore.js 1.3.3, copyright 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. * @@ -3341,7 +3341,7 @@ * @memberOf _ * @type String */ - lodash.VERSION = '0.3.0'; + lodash.VERSION = '0.3.1'; // assign static methods lodash.after = after; diff --git a/lodash.min.js b/lodash.min.js index 1d6711d5ea..3f7362284a 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,5 +1,5 @@ /*! - Lo-Dash 0.3.0 lodash.com/license + Lo-Dash 0.3.1 lodash.com/license Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE */ ;(function(e,t){"use strict";function s(e){return"[object Arguments]"==rt.call(e)}function o(e){return new u(e)}function u(e){if(e&&e._wrapped)return e;this._wrapped=e}function a(){for(var e,t,s,o=-1,u=arguments.length,a={e:"",f:"",k:"",q:"",c:{d:"",m:"++k/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"};var lt=Function("obj","var __p;with(obj){__p='var k,r';if(k){__p+='='+k};__p+=';'+f+';'+q+';';if(c){__p+='var m='+g+'.length;k=-1;';if(o){__p+='if(m===m>>>0){'};__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&&k==\\'prototype\\')';if(r){__p+='&&'+h};__p+='){'+o['j']+'}'};__p+='}';if(i){__p+='var f='+l+'.constructor;';for(var k=0;k<7;k++){__p+='k=\\''+p[k]+'\\';if(';if(p[k]=='constructor'){__p+='!(f&&f.prototype==='+l+')&&'};__p+=''+h+'){'+o['j']+'}'}}if(c){__p+='}'}};__p+=''+e+';return r'}return __p" ),ct={a:"e,c,x",k:"e",q:"if(!c){c=j}else if(x){c=l(c,x)}",j:"c(e[k],k,e)"},ht={k:"z",j:"if(!c(e[k],k,e))return!r"},pt={a:"n",k:"n",q:"for(var t,u=1,m=arguments.length;ue?t():function(){if(1>--e)return t.apply(this,arguments)}},o.bind=C,o.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=Nt(e));for( +,e:"r.sort()"});s(arguments)||(s=function(e){return!!e&&!!et.call(e,"callee")});var Ct=st||function(e){return rt.call(e)==W},st=a({a:"B",k:"z",q:"var d=y.call(B);if(d==b||d==v)return!B.length",j:{n:"return g"}}),kt=ut?function(e){return"function"==typeof e?gt(e):ut(e)}:gt,Lt=a({a:"n",k:"[]",j:"r.push(n[k])"});o.VERSION="0.3.1",o.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},o.bind=C,o.bindAll=function(e){var t=arguments,n=1;1==t.length&&(n=0,t=Nt(e));for( var r=t.length;nw(i,e[n])&&t.push(e[n]);return t},o.escape=function(e){return(e+"").replace(B,c)},o.every=yt,o.extend=Tt ,o.filter=Y,o.find=bt,o.first=y,o.flatten=b,o.forEach=wt,o.forIn=pt,o.forOwn=ct,o.functions=Nt,o.groupBy=function(e,t,n){var r={};if(!e)return r;var i,s=-1,o="function"==typeof t,u=e.length;for(o&&n&&(t=h(t,n));++s