mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Add _.countBy and related unit tests, benchmarks, and documentation.
Former-commit-id: 915eaf414883a1dc344a558b08c7a1337ab5a225
This commit is contained in:
5
build.js
5
build.js
@@ -153,6 +153,7 @@
|
||||
'compact': [],
|
||||
'compose': [],
|
||||
'contains': [],
|
||||
'countBy': [],
|
||||
'debounce': [],
|
||||
'defaults': [],
|
||||
'defer': [],
|
||||
@@ -260,10 +261,12 @@
|
||||
allMethods = Object.keys(dependencyMap);
|
||||
|
||||
var underscoreMethods = lodash.without.apply(lodash, [allMethods].concat([
|
||||
'countBy',
|
||||
'drop',
|
||||
'forIn',
|
||||
'forOwn',
|
||||
'partial'
|
||||
'partial',
|
||||
'zipObject'
|
||||
]));
|
||||
|
||||
/** Used to specify whether filtering is for exclusion or inclusion */
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
'target',
|
||||
'thisArg',
|
||||
'toString',
|
||||
'value'
|
||||
'value',
|
||||
'valueProp'
|
||||
];
|
||||
|
||||
/** Used to minify `compileIterator` option properties */
|
||||
@@ -93,6 +94,7 @@
|
||||
'compact',
|
||||
'compose',
|
||||
'contains',
|
||||
'countBy',
|
||||
'criteria',
|
||||
'debounce',
|
||||
'defaults',
|
||||
|
||||
254
doc/README.md
254
doc/README.md
@@ -16,6 +16,7 @@
|
||||
* [`_.compact`](#_compactarray)
|
||||
* [`_.compose`](#_composefunc1-func2-)
|
||||
* [`_.contains`](#_containscollection-target)
|
||||
* [`_.countBy`](#_countbycollection-callback--thisarg)
|
||||
* [`_.debounce`](#_debouncefunc-wait-immediate)
|
||||
* [`_.defaults`](#_defaultsobject--default1-default2-)
|
||||
* [`_.defer`](#_deferfunc--arg1-arg2-)
|
||||
@@ -90,7 +91,7 @@
|
||||
* [`_.uniqueId`](#_uniqueidprefix)
|
||||
* [`_.values`](#_valuesobject)
|
||||
* [`_.without`](#_withoutarray--value1-value2-)
|
||||
* [`_.wrap`](#_wrapfunc-wrapper--arg1-arg2-)
|
||||
* [`_.wrap`](#_wrapfunc-wrapper)
|
||||
* [`_.zip`](#_ziparray1-array2-)
|
||||
* [`_.zipObject`](#_zipobjectkeys)
|
||||
|
||||
@@ -149,7 +150,7 @@ The `lodash` function.
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_version"></a>`_.VERSION`
|
||||
<a href="#_version">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3646 "View in source") [Ⓣ][1]
|
||||
<a href="#_version">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3674 "View in source") [Ⓣ][1]
|
||||
|
||||
*(String)*: The semantic version number.
|
||||
|
||||
@@ -161,7 +162,7 @@ The `lodash` function.
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_aftern-func"></a>`_.after(n, func)`
|
||||
<a href="#_aftern-func">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1991 "View in source") [Ⓣ][1]
|
||||
<a href="#_aftern-func">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2020 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a new function that is restricted to executing only after it is called `n` times.
|
||||
|
||||
@@ -189,7 +190,7 @@ _.forEach(notes, function(note) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_bindfunc--thisarg-arg1-arg2-"></a>`_.bind(func [, thisArg, arg1, arg2, ...])`
|
||||
<a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2045 "View in source") [Ⓣ][1]
|
||||
<a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2074 "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`.
|
||||
|
||||
@@ -240,7 +241,7 @@ func();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_bindallobject--methodname1-methodname2-"></a>`_.bindAll(object [, methodName1, methodName2, ...])`
|
||||
<a href="#_bindallobject--methodname1-methodname2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2115 "View in source") [Ⓣ][1]
|
||||
<a href="#_bindallobject--methodname1-methodname2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2144 "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.
|
||||
|
||||
@@ -271,7 +272,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_chainvalue"></a>`_.chain(value)`
|
||||
<a href="#_chainvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3571 "View in source") [Ⓣ][1]
|
||||
<a href="#_chainvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3599 "View in source") [Ⓣ][1]
|
||||
|
||||
Wraps the value in a `lodash` wrapper object.
|
||||
|
||||
@@ -305,7 +306,7 @@ var youngest = _.chain(stooges)
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_clonevalue"></a>`_.clone(value)`
|
||||
<a href="#_clonevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2445 "View in source") [Ⓣ][1]
|
||||
<a href="#_clonevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2473 "View in source") [Ⓣ][1]
|
||||
|
||||
Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned.
|
||||
|
||||
@@ -329,9 +330,9 @@ _.clone({ 'name': 'moe' });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_compactarray"></a>`_.compact(array)`
|
||||
<a href="#_compactarray">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1233 "View in source") [Ⓣ][1]
|
||||
<a href="#_compactarray">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1263 "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.
|
||||
Creates a new array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to compact.
|
||||
@@ -353,7 +354,7 @@ _.compact([0, 1, false, 2, '', 3]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_composefunc1-func2-"></a>`_.compose([func1, func2, ...])`
|
||||
<a href="#_composefunc1-func2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2151 "View in source") [Ⓣ][1]
|
||||
<a href="#_composefunc1-func2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2180 "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()))`.
|
||||
|
||||
@@ -380,7 +381,7 @@ welcome('moe');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_containscollection-target"></a>`_.contains(collection, target)`
|
||||
<a href="#_containscollection-target">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L768 "View in source") [Ⓣ][1]
|
||||
<a href="#_containscollection-target">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L785 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if a given `target` value is present in a `collection` using strict equality for comparisons, i.e. `===`.
|
||||
|
||||
@@ -408,10 +409,42 @@ _.contains('curly', 'ur');
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_countbycollection-callback--thisarg"></a>`_.countBy(collection, callback [, thisArg])`
|
||||
<a href="#_countbycollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L821 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*.
|
||||
|
||||
#### Arguments
|
||||
1. `collection` *(Array|Object|String)*: The collection to iterate over.
|
||||
2. `callback` *(Function|String)*: The function called per iteration or property name to count by.
|
||||
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
|
||||
|
||||
#### Returns
|
||||
*(Object)*: Returns the composed aggregate object.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
|
||||
// => { '4': 1, '6': 2 }
|
||||
|
||||
_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
||||
// => { '4': 1, '6': 2 }
|
||||
|
||||
_.countBy(['one', 'two', 'three'], 'length');
|
||||
// => { '3': 2, '5': 1 }
|
||||
~~~
|
||||
|
||||
* * *
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_debouncefunc-wait-immediate"></a>`_.debounce(func, wait, immediate)`
|
||||
<a href="#_debouncefunc-wait-immediate">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2184 "View in source") [Ⓣ][1]
|
||||
<a href="#_debouncefunc-wait-immediate">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2213 "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.
|
||||
|
||||
@@ -437,7 +470,7 @@ jQuery(window).on('resize', lazyLayout);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_defaultsobject--default1-default2-"></a>`_.defaults(object [, default1, default2, ...])`
|
||||
<a href="#_defaultsobject--default1-default2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2469 "View in source") [Ⓣ][1]
|
||||
<a href="#_defaultsobject--default1-default2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2497 "View in source") [Ⓣ][1]
|
||||
|
||||
Assigns enumerable properties of the default object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored.
|
||||
|
||||
@@ -463,9 +496,9 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_deferfunc--arg1-arg2-"></a>`_.defer(func [, arg1, arg2, ...])`
|
||||
<a href="#_deferfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2249 "View in source") [Ⓣ][1]
|
||||
<a href="#_deferfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2278 "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.
|
||||
Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked.
|
||||
|
||||
#### Arguments
|
||||
1. `func` *(Function)*: The function to defer.
|
||||
@@ -488,9 +521,9 @@ _.defer(function() { alert('deferred'); });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_delayfunc-wait--arg1-arg2-"></a>`_.delay(func, wait [, arg1, arg2, ...])`
|
||||
<a href="#_delayfunc-wait--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2229 "View in source") [Ⓣ][1]
|
||||
<a href="#_delayfunc-wait--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2258 "View in source") [Ⓣ][1]
|
||||
|
||||
Executes the `func` function after `wait` milliseconds. Additional arguments are passed to `func` when it is invoked.
|
||||
Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked.
|
||||
|
||||
#### Arguments
|
||||
1. `func` *(Function)*: The function to delay.
|
||||
@@ -515,9 +548,9 @@ _.delay(log, 1000, 'logged later');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_differencearray--array1-array2-"></a>`_.difference(array [, array1, array2, ...])`
|
||||
<a href="#_differencearray--array1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1265 "View in source") [Ⓣ][1]
|
||||
<a href="#_differencearray--array1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1295 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`.
|
||||
Creates a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`.
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to process.
|
||||
@@ -540,7 +573,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_dropobject--prop1-prop2-"></a>`_.drop(object [, prop1, prop2, ...])`
|
||||
<a href="#_dropobject--prop1-prop2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2489 "View in source") [Ⓣ][1]
|
||||
<a href="#_dropobject--prop1-prop2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names.
|
||||
|
||||
@@ -565,7 +598,7 @@ _.drop({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'userid');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_escapestring"></a>`_.escape(string)`
|
||||
<a href="#_escapestring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3206 "View in source") [Ⓣ][1]
|
||||
<a href="#_escapestring">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3234 "View in source") [Ⓣ][1]
|
||||
|
||||
Escapes a string for inclusion in HTML, replacing `&`, `<`, `"`, and `'` characters.
|
||||
|
||||
@@ -589,7 +622,7 @@ _.escape('Curly, Larry & Moe');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_everycollection--callbackidentity-thisarg"></a>`_.every(collection [, callback=identity, thisArg])`
|
||||
<a href="#_everycollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L796 "View in source") [Ⓣ][1]
|
||||
<a href="#_everycollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L841 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*.
|
||||
|
||||
@@ -615,7 +648,7 @@ _.every([true, 1, null, 'yes'], Boolean);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_extendobject--source1-source2-"></a>`_.extend(object [, source1, source2, ...])`
|
||||
<a href="#_extendobject--source1-source2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2513 "View in source") [Ⓣ][1]
|
||||
<a href="#_extendobject--source1-source2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2541 "View in source") [Ⓣ][1]
|
||||
|
||||
Assigns enumerable properties of the source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources.
|
||||
|
||||
@@ -640,7 +673,7 @@ _.extend({ 'name': 'moe' }, { 'age': 40 });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_filtercollection--callbackidentity-thisarg"></a>`_.filter(collection [, callback=identity, thisArg])`
|
||||
<a href="#_filtercollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L816 "View in source") [Ⓣ][1]
|
||||
<a href="#_filtercollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L861 "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; *(value, index|key, collection)*.
|
||||
|
||||
@@ -666,7 +699,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; })
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_findcollection-callback--thisarg"></a>`_.find(collection, callback [, thisArg])`
|
||||
<a href="#_findcollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L837 "View in source") [Ⓣ][1]
|
||||
<a href="#_findcollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L882 "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; *(value, index|key, collection)*.
|
||||
|
||||
@@ -692,7 +725,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_firstarray--n-guard"></a>`_.first(array [, n, guard])`
|
||||
<a href="#_firstarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1302 "View in source") [Ⓣ][1]
|
||||
<a href="#_firstarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1332 "View in source") [Ⓣ][1]
|
||||
|
||||
Gets the first value of the `array`. Pass `n` to return the first `n` values of the `array`.
|
||||
|
||||
@@ -718,7 +751,7 @@ _.first([5, 4, 3, 2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_flattenarray-shallow"></a>`_.flatten(array, shallow)`
|
||||
<a href="#_flattenarray-shallow">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1326 "View in source") [Ⓣ][1]
|
||||
<a href="#_flattenarray-shallow">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1356 "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.
|
||||
|
||||
@@ -746,7 +779,7 @@ _.flatten([1, [2], [3, [[4]]]], true);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_foreachcollection-callback--thisarg"></a>`_.forEach(collection, callback [, thisArg])`
|
||||
<a href="#_foreachcollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L863 "View in source") [Ⓣ][1]
|
||||
<a href="#_foreachcollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L908 "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; *(value, index|key, collection)*.
|
||||
|
||||
@@ -775,7 +808,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_forinobject-callback--thisarg"></a>`_.forIn(object, callback [, thisArg])`
|
||||
<a href="#_forinobject-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2542 "View in source") [Ⓣ][1]
|
||||
<a href="#_forinobject-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2570 "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)*.
|
||||
|
||||
@@ -811,7 +844,7 @@ _.forIn(new Dog('Dagny'), function(value, key) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_forownobject-callback--thisarg"></a>`_.forOwn(object, callback [, thisArg])`
|
||||
<a href="#_forownobject-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2565 "View in source") [Ⓣ][1]
|
||||
<a href="#_forownobject-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2593 "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)*.
|
||||
|
||||
@@ -839,9 +872,9 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_functionsobject"></a>`_.functions(object)`
|
||||
<a href="#_functionsobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2582 "View in source") [Ⓣ][1]
|
||||
<a href="#_functionsobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2610 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces a sorted array of the enumerable properties, own and inherited, of `object` that have function values.
|
||||
Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values.
|
||||
|
||||
#### Arguments
|
||||
1. `object` *(Object)*: The object to inspect.
|
||||
@@ -863,9 +896,9 @@ _.functions(_);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_groupbycollection-callback--thisarg"></a>`_.groupBy(collection, callback [, thisArg])`
|
||||
<a href="#_groupbycollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L890 "View in source") [Ⓣ][1]
|
||||
<a href="#_groupbycollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L936 "View in source") [Ⓣ][1]
|
||||
|
||||
Splits `collection` 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|key, collection)*. The `callback` argument may also be the name of a property to group by.
|
||||
Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*.
|
||||
|
||||
#### Arguments
|
||||
1. `collection` *(Array|Object|String)*: The collection to iterate over.
|
||||
@@ -873,15 +906,15 @@ Splits `collection` into sets, grouped by the result of running each value throu
|
||||
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
|
||||
|
||||
#### Returns
|
||||
*(Object)*: Returns an object of grouped values.
|
||||
*(Object)*: Returns the composed aggregate object.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
_.groupBy([1.3, 2.1, 2.4], function(num) { return Math.floor(num); });
|
||||
// => { '1': [1.3], '2': [2.1, 2.4] }
|
||||
_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
|
||||
// => { '4': [4.2], '6': [6.1, 6.4] }
|
||||
|
||||
_.groupBy([1.3, 2.1, 2.4], function(num) { return this.floor(num); }, Math);
|
||||
// => { '1': [1.3], '2': [2.1, 2.4] }
|
||||
_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
||||
// => { '4': [4.2], '6': [6.1, 6.4] }
|
||||
|
||||
_.groupBy(['one', 'two', 'three'], 'length');
|
||||
// => { '3': ['one', 'two'], '5': ['three'] }
|
||||
@@ -895,7 +928,7 @@ _.groupBy(['one', 'two', 'three'], 'length');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_hasobject-property"></a>`_.has(object, property)`
|
||||
<a href="#_hasobject-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2605 "View in source") [Ⓣ][1]
|
||||
<a href="#_hasobject-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2633 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if the specified object `property` exists and is a direct property, instead of an inherited property.
|
||||
|
||||
@@ -920,7 +953,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_identityvalue"></a>`_.identity(value)`
|
||||
<a href="#_identityvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3225 "View in source") [Ⓣ][1]
|
||||
<a href="#_identityvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3253 "View in source") [Ⓣ][1]
|
||||
|
||||
This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback.
|
||||
|
||||
@@ -945,7 +978,7 @@ moe === _.identity(moe);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_indexofarray-value--fromindex0"></a>`_.indexOf(array, value [, fromIndex=0])`
|
||||
<a href="#_indexofarray-value--fromindex0">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1370 "View in source") [Ⓣ][1]
|
||||
<a href="#_indexofarray-value--fromindex0">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1400 "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.
|
||||
|
||||
@@ -977,7 +1010,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_initialarray--n-guard"></a>`_.initial(array [, n, guard])`
|
||||
<a href="#_initialarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1410 "View in source") [Ⓣ][1]
|
||||
<a href="#_initialarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1440 "View in source") [Ⓣ][1]
|
||||
|
||||
Gets all but the last value of `array`. Pass `n` to exclude the last `n` values from the result.
|
||||
|
||||
@@ -1003,7 +1036,7 @@ _.initial([3, 2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_intersectionarray1-array2-"></a>`_.intersection([array1, array2, ...])`
|
||||
<a href="#_intersectionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1431 "View in source") [Ⓣ][1]
|
||||
<a href="#_intersectionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1461 "View in source") [Ⓣ][1]
|
||||
|
||||
Computes the intersection of all the passed-in arrays.
|
||||
|
||||
@@ -1027,7 +1060,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_invokecollection-methodname--arg1-arg2-"></a>`_.invoke(collection, methodName [, arg1, arg2, ...])`
|
||||
<a href="#_invokecollection-methodname--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L924 "View in source") [Ⓣ][1]
|
||||
<a href="#_invokecollection-methodname--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L964 "View in source") [Ⓣ][1]
|
||||
|
||||
Invokes the method named by `methodName` on each element in the `collection`. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`.
|
||||
|
||||
@@ -1056,7 +1089,7 @@ _.invoke([123, 456], String.prototype.split, '');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isargumentsvalue"></a>`_.isArguments(value)`
|
||||
<a href="#_isargumentsvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2625 "View in source") [Ⓣ][1]
|
||||
<a href="#_isargumentsvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is an `arguments` object.
|
||||
|
||||
@@ -1083,7 +1116,7 @@ _.isArguments([1, 2, 3]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isarrayvalue"></a>`_.isArray(value)`
|
||||
<a href="#_isarrayvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2652 "View in source") [Ⓣ][1]
|
||||
<a href="#_isarrayvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2680 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is an array.
|
||||
|
||||
@@ -1110,7 +1143,7 @@ _.isArray([1, 2, 3]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isbooleanvalue"></a>`_.isBoolean(value)`
|
||||
<a href="#_isbooleanvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2669 "View in source") [Ⓣ][1]
|
||||
<a href="#_isbooleanvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2697 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a boolean *(`true` or `false`)* value.
|
||||
|
||||
@@ -1134,7 +1167,7 @@ _.isBoolean(null);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isdatevalue"></a>`_.isDate(value)`
|
||||
<a href="#_isdatevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2686 "View in source") [Ⓣ][1]
|
||||
<a href="#_isdatevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2714 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a date.
|
||||
|
||||
@@ -1158,7 +1191,7 @@ _.isDate(new Date);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_iselementvalue"></a>`_.isElement(value)`
|
||||
<a href="#_iselementvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2703 "View in source") [Ⓣ][1]
|
||||
<a href="#_iselementvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2731 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a DOM element.
|
||||
|
||||
@@ -1182,7 +1215,7 @@ _.isElement(document.body);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isemptyvalue"></a>`_.isEmpty(value)`
|
||||
<a href="#_isemptyvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2727 "View in source") [Ⓣ][1]
|
||||
<a href="#_isemptyvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2755 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is empty. Arrays or strings with a length of `0` and objects with no own enumerable properties are considered "empty".
|
||||
|
||||
@@ -1212,7 +1245,7 @@ _.isEmpty('');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isequala-b--stack"></a>`_.isEqual(a, b [, stack])`
|
||||
<a href="#_isequala-b--stack">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2761 "View in source") [Ⓣ][1]
|
||||
<a href="#_isequala-b--stack">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2789 "View in source") [Ⓣ][1]
|
||||
|
||||
Performs a deep comparison between two values to determine if they are equivalent to each other.
|
||||
|
||||
@@ -1244,7 +1277,7 @@ _.isEqual(moe, clone);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isfinitevalue"></a>`_.isFinite(value)`
|
||||
<a href="#_isfinitevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2923 "View in source") [Ⓣ][1]
|
||||
<a href="#_isfinitevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2951 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and other values. See http://es5.github.com/#x15.1.2.5.
|
||||
|
||||
@@ -1274,7 +1307,7 @@ _.isFinite(Infinity);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isfunctionvalue"></a>`_.isFunction(value)`
|
||||
<a href="#_isfunctionvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2940 "View in source") [Ⓣ][1]
|
||||
<a href="#_isfunctionvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2968 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a function.
|
||||
|
||||
@@ -1298,7 +1331,7 @@ _.isFunction(''.concat);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isnanvalue"></a>`_.isNaN(value)`
|
||||
<a href="#_isnanvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2992 "View in source") [Ⓣ][1]
|
||||
<a href="#_isnanvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3020 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return true for `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
|
||||
|
||||
@@ -1331,7 +1364,7 @@ _.isNaN(undefined);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isnullvalue"></a>`_.isNull(value)`
|
||||
<a href="#_isnullvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3015 "View in source") [Ⓣ][1]
|
||||
<a href="#_isnullvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3043 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is `null`.
|
||||
|
||||
@@ -1358,7 +1391,7 @@ _.isNull(undefined);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isnumbervalue"></a>`_.isNumber(value)`
|
||||
<a href="#_isnumbervalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3032 "View in source") [Ⓣ][1]
|
||||
<a href="#_isnumbervalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3060 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a number.
|
||||
|
||||
@@ -1382,7 +1415,7 @@ _.isNumber(8.4 * 5;
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isobjectvalue"></a>`_.isObject(value)`
|
||||
<a href="#_isobjectvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2961 "View in source") [Ⓣ][1]
|
||||
<a href="#_isobjectvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2989 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexps, `new Number(0)`, and `new String('')`)*
|
||||
|
||||
@@ -1409,7 +1442,7 @@ _.isObject(1);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isregexpvalue"></a>`_.isRegExp(value)`
|
||||
<a href="#_isregexpvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3049 "View in source") [Ⓣ][1]
|
||||
<a href="#_isregexpvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3077 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a regular expression.
|
||||
|
||||
@@ -1433,7 +1466,7 @@ _.isRegExp(/moe/);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isstringvalue"></a>`_.isString(value)`
|
||||
<a href="#_isstringvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3066 "View in source") [Ⓣ][1]
|
||||
<a href="#_isstringvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3094 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is a string.
|
||||
|
||||
@@ -1457,7 +1490,7 @@ _.isString('moe');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_isundefinedvalue"></a>`_.isUndefined(value)`
|
||||
<a href="#_isundefinedvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3084 "View in source") [Ⓣ][1]
|
||||
<a href="#_isundefinedvalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3112 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if `value` is `undefined`.
|
||||
|
||||
@@ -1481,9 +1514,9 @@ _.isUndefined(void 0);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_keysobject"></a>`_.keys(object)`
|
||||
<a href="#_keysobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [Ⓣ][1]
|
||||
<a href="#_keysobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3129 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces an array of object`'s own enumerable property names.
|
||||
Creates an array composed of the own enumerable property names of `object`.
|
||||
|
||||
#### Arguments
|
||||
1. `object` *(Object)*: The object to inspect.
|
||||
@@ -1505,7 +1538,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_lastarray--n-guard"></a>`_.last(array [, n, guard])`
|
||||
<a href="#_lastarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1472 "View in source") [Ⓣ][1]
|
||||
<a href="#_lastarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1502 "View in source") [Ⓣ][1]
|
||||
|
||||
Gets the last value of the `array`. Pass `n` to return the lasy `n` values of the `array`.
|
||||
|
||||
@@ -1531,7 +1564,7 @@ _.last([3, 2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_lastindexofarray-value--fromindexarraylength-1"></a>`_.lastIndexOf(array, value [, fromIndex=array.length-1])`
|
||||
<a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1498 "View in source") [Ⓣ][1]
|
||||
<a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1528 "View in source") [Ⓣ][1]
|
||||
|
||||
Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`.
|
||||
|
||||
@@ -1560,9 +1593,9 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_mapcollection--callbackidentity-thisarg"></a>`_.map(collection [, callback=identity, thisArg])`
|
||||
<a href="#_mapcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L960 "View in source") [Ⓣ][1]
|
||||
<a href="#_mapcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1000 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces a new array of values by mapping each element in the `collection` through a transformation `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*.
|
||||
Creates a new array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*.
|
||||
|
||||
#### Arguments
|
||||
1. `collection` *(Array|Object|String)*: The collection to iterate over.
|
||||
@@ -1589,7 +1622,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_maxarray--callback-thisarg"></a>`_.max(array [, callback, thisArg])`
|
||||
<a href="#_maxarray--callback-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1538 "View in source") [Ⓣ][1]
|
||||
<a href="#_maxarray--callback-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1568 "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)*.
|
||||
|
||||
@@ -1621,7 +1654,7 @@ _.max(stooges, function(stooge) { return stooge.age; });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_memoizefunc--resolver"></a>`_.memoize(func [, resolver])`
|
||||
<a href="#_memoizefunc--resolver">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2272 "View in source") [Ⓣ][1]
|
||||
<a href="#_memoizefunc--resolver">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2301 "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.
|
||||
|
||||
@@ -1647,7 +1680,7 @@ var fibonacci = _.memoize(function(n) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_minarray--callback-thisarg"></a>`_.min(array [, callback, thisArg])`
|
||||
<a href="#_minarray--callback-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1588 "View in source") [Ⓣ][1]
|
||||
<a href="#_minarray--callback-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1618 "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)*.
|
||||
|
||||
@@ -1673,7 +1706,7 @@ _.min([10, 5, 100, 2, 1000]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_mixinobject"></a>`_.mixin(object)`
|
||||
<a href="#_mixinobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3251 "View in source") [Ⓣ][1]
|
||||
<a href="#_mixinobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3279 "View in source") [Ⓣ][1]
|
||||
|
||||
Adds functions properties of `object` to the `lodash` function and chainable wrapper.
|
||||
|
||||
@@ -1703,7 +1736,7 @@ _('larry').capitalize();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_noconflict"></a>`_.noConflict()`
|
||||
<a href="#_noconflict">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3282 "View in source") [Ⓣ][1]
|
||||
<a href="#_noconflict">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3310 "View in source") [Ⓣ][1]
|
||||
|
||||
Reverts the '_' variable to its previous value and returns a reference to the `lodash` function.
|
||||
|
||||
@@ -1723,7 +1756,7 @@ var lodash = _.noConflict();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_oncefunc"></a>`_.once(func)`
|
||||
<a href="#_oncefunc">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2298 "View in source") [Ⓣ][1]
|
||||
<a href="#_oncefunc">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2327 "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.
|
||||
|
||||
@@ -1749,7 +1782,7 @@ initialize();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_partialfunc--arg1-arg2-"></a>`_.partial(func [, arg1, arg2, ...])`
|
||||
<a href="#_partialfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2331 "View in source") [Ⓣ][1]
|
||||
<a href="#_partialfunc--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2360 "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.
|
||||
|
||||
@@ -1776,7 +1809,7 @@ hi('moe');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_pickobject--prop1-prop2-"></a>`_.pick(object [, prop1, prop2, ...])`
|
||||
<a href="#_pickobject--prop1-prop2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3124 "View in source") [Ⓣ][1]
|
||||
<a href="#_pickobject--prop1-prop2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names.
|
||||
|
||||
@@ -1801,7 +1834,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_pluckcollection-property"></a>`_.pluck(collection, property)`
|
||||
<a href="#_pluckcollection-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L983 "View in source") [Ⓣ][1]
|
||||
<a href="#_pluckcollection-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1023 "View in source") [Ⓣ][1]
|
||||
|
||||
Retrieves the value of a specified property from all elements in the `collection`.
|
||||
|
||||
@@ -1832,7 +1865,7 @@ _.pluck(stooges, 'name');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_rangestart0-end--step1"></a>`_.range([start=0], end [, step=1])`
|
||||
<a href="#_rangestart0-end--step1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1]
|
||||
<a href="#_rangestart0-end--step1">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1679 "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.
|
||||
|
||||
@@ -1870,7 +1903,7 @@ _.range(0);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_reducecollection-callback--accumulator-thisarg"></a>`_.reduce(collection, callback [, accumulator, thisArg])`
|
||||
<a href="#_reducecollection-callback--accumulator-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1011 "View in source") [Ⓣ][1]
|
||||
<a href="#_reducecollection-callback--accumulator-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1051 "View in source") [Ⓣ][1]
|
||||
|
||||
Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*.
|
||||
|
||||
@@ -1897,7 +1930,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_reducerightcollection-callback--accumulator-thisarg"></a>`_.reduceRight(collection, callback [, accumulator, thisArg])`
|
||||
<a href="#_reducerightcollection-callback--accumulator-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1048 "View in source") [Ⓣ][1]
|
||||
<a href="#_reducerightcollection-callback--accumulator-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1088 "View in source") [Ⓣ][1]
|
||||
|
||||
The right-associative version of `_.reduce`.
|
||||
|
||||
@@ -1925,7 +1958,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_rejectcollection--callbackidentity-thisarg"></a>`_.reject(collection [, callback=identity, thisArg])`
|
||||
<a href="#_rejectcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1103 "View in source") [Ⓣ][1]
|
||||
<a href="#_rejectcollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1143 "View in source") [Ⓣ][1]
|
||||
|
||||
The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for.
|
||||
|
||||
@@ -1951,7 +1984,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_restarray--n-guard"></a>`_.rest(array [, n, guard])`
|
||||
<a href="#_restarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1686 "View in source") [Ⓣ][1]
|
||||
<a href="#_restarray--n-guard">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1716 "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.
|
||||
|
||||
@@ -1977,7 +2010,7 @@ _.rest([3, 2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_resultobject-property"></a>`_.result(object, property)`
|
||||
<a href="#_resultobject-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3314 "View in source") [Ⓣ][1]
|
||||
<a href="#_resultobject-property">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3342 "View in source") [Ⓣ][1]
|
||||
|
||||
Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned.
|
||||
|
||||
@@ -2012,9 +2045,9 @@ _.result(object, 'stuff');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_shufflearray"></a>`_.shuffle(array)`
|
||||
<a href="#_shufflearray">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1707 "View in source") [Ⓣ][1]
|
||||
<a href="#_shufflearray">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1737 "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.
|
||||
Creates a new array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to shuffle.
|
||||
@@ -2036,7 +2069,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_sizevalue"></a>`_.size(value)`
|
||||
<a href="#_sizevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3163 "View in source") [Ⓣ][1]
|
||||
<a href="#_sizevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3191 "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.
|
||||
|
||||
@@ -2066,7 +2099,7 @@ _.size('curly');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_somecollection--callbackidentity-thisarg"></a>`_.some(collection [, callback=identity, thisArg])`
|
||||
<a href="#_somecollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1126 "View in source") [Ⓣ][1]
|
||||
<a href="#_somecollection--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1166 "View in source") [Ⓣ][1]
|
||||
|
||||
Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*.
|
||||
|
||||
@@ -2092,9 +2125,9 @@ _.some([null, 0, 'yes', false]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_sortbycollection-callback--thisarg"></a>`_.sortBy(collection, callback [, thisArg])`
|
||||
<a href="#_sortbycollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1158 "View in source") [Ⓣ][1]
|
||||
<a href="#_sortbycollection-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1196 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces a new sorted array, sorted in ascending order by the results of running each element of `collection` through a transformation `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*.
|
||||
Creates a new sorted array, sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*.
|
||||
|
||||
#### Arguments
|
||||
1. `collection` *(Array|Object|String)*: The collection to iterate over.
|
||||
@@ -2124,7 +2157,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_sortedindexarray-value--callbackidentity-thisarg"></a>`_.sortedIndex(array, value [, callback=identity, thisArg])`
|
||||
<a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1759 "View in source") [Ⓣ][1]
|
||||
<a href="#_sortedindexarray-value--callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1789 "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)*.
|
||||
|
||||
@@ -2165,12 +2198,12 @@ _.sortedIndex(['twenty', 'thirty', 'fourty'], 'thirty-five', function(word) {
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)`
|
||||
<a href="#_tapvalue-interceptor">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3598 "View in source") [Ⓣ][1]
|
||||
<a href="#_tapvalue-interceptor">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3626 "View in source") [Ⓣ][1]
|
||||
|
||||
Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
|
||||
|
||||
#### Arguments
|
||||
1. `value` *(Mixed)*: The value to pass to `callback`.
|
||||
1. `value` *(Mixed)*: The value to pass to `interceptor`.
|
||||
2. `interceptor` *(Function)*: The function to invoke.
|
||||
|
||||
#### Returns
|
||||
@@ -2195,7 +2228,7 @@ _.chain([1,2,3,200])
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_templatetext-data-options"></a>`_.template(text, data, options)`
|
||||
<a href="#_templatetext-data-options">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3374 "View in source") [Ⓣ][1]
|
||||
<a href="#_templatetext-data-options">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3402 "View in source") [Ⓣ][1]
|
||||
|
||||
A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
|
||||
|
||||
@@ -2254,7 +2287,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_throttlefunc-wait"></a>`_.throttle(func, wait)`
|
||||
<a href="#_throttlefunc-wait">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2367 "View in source") [Ⓣ][1]
|
||||
<a href="#_throttlefunc-wait">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2396 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a new function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call.
|
||||
|
||||
@@ -2279,7 +2312,7 @@ jQuery(window).on('scroll', throttled);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_timesn-callback--thisarg"></a>`_.times(n, callback [, thisArg])`
|
||||
<a href="#_timesn-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3514 "View in source") [Ⓣ][1]
|
||||
<a href="#_timesn-callback--thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3542 "View in source") [Ⓣ][1]
|
||||
|
||||
Executes the `callback` function `n` times. The `callback` is bound to `thisArg` and invoked with `1` argument; *(index)*.
|
||||
|
||||
@@ -2305,7 +2338,7 @@ _.times(3, function() { this.grantWish(); }, genie);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_toarraycollection"></a>`_.toArray(collection)`
|
||||
<a href="#_toarraycollection">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1201 "View in source") [Ⓣ][1]
|
||||
<a href="#_toarraycollection">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1231 "View in source") [Ⓣ][1]
|
||||
|
||||
Converts the `collection`, into an array. Useful for converting the `arguments` object.
|
||||
|
||||
@@ -2329,7 +2362,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments`
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_unionarray1-array2-"></a>`_.union([array1, array2, ...])`
|
||||
<a href="#_unionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1799 "View in source") [Ⓣ][1]
|
||||
<a href="#_unionarray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1829 "View in source") [Ⓣ][1]
|
||||
|
||||
Computes the union of the passed-in arrays.
|
||||
|
||||
@@ -2353,9 +2386,9 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_uniqarray--issortedfalse-callbackidentity-thisarg"></a>`_.uniq(array [, isSorted=false, callback=identity, thisArg])`
|
||||
<a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1844 "View in source") [Ⓣ][1]
|
||||
<a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1873 "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)*.
|
||||
Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with `3` arguments; *(value, index, array)*.
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to process.
|
||||
@@ -2389,7 +2422,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_uniqueidprefix"></a>`_.uniqueId([prefix])`
|
||||
<a href="#_uniqueidprefix">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3541 "View in source") [Ⓣ][1]
|
||||
<a href="#_uniqueidprefix">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3569 "View in source") [Ⓣ][1]
|
||||
|
||||
Generates a unique id. If `prefix` is passed, the id will be appended to it.
|
||||
|
||||
@@ -2413,9 +2446,9 @@ _.uniqueId('contact_');
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_valuesobject"></a>`_.values(object)`
|
||||
<a href="#_valuesobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3184 "View in source") [Ⓣ][1]
|
||||
<a href="#_valuesobject">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3212 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces an array of `object`'s own enumerable property values.
|
||||
Creates an array composed of the own enumerable property values of `object`.
|
||||
|
||||
#### Arguments
|
||||
1. `object` *(Object)*: The object to inspect.
|
||||
@@ -2437,9 +2470,9 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_withoutarray--value1-value2-"></a>`_.without(array [, value1, value2, ...])`
|
||||
<a href="#_withoutarray--value1-value2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1893 "View in source") [Ⓣ][1]
|
||||
<a href="#_withoutarray--value1-value2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1922 "View in source") [Ⓣ][1]
|
||||
|
||||
Produces a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`.
|
||||
Creates a new array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`.
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to filter.
|
||||
@@ -2461,15 +2494,14 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_wrapfunc-wrapper--arg1-arg2-"></a>`_.wrap(func, wrapper [, arg1, arg2, ...])`
|
||||
<a href="#_wrapfunc-wrapper--arg1-arg2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2419 "View in source") [Ⓣ][1]
|
||||
### <a id="_wrapfunc-wrapper"></a>`_.wrap(func, wrapper)`
|
||||
<a href="#_wrapfunc-wrapper">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2447 "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.
|
||||
Create a new function that passes `func` to the `wrapper` function as its first argument. Additional arguments passed to the new function are appended to those passed to the `wrapper` function.
|
||||
|
||||
#### Arguments
|
||||
1. `func` *(Function)*: The function to wrap.
|
||||
2. `wrapper` *(Function)*: The wrapper function.
|
||||
3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to append to those passed to the wrapper.
|
||||
|
||||
#### Returns
|
||||
*(Function)*: Returns the new function.
|
||||
@@ -2492,7 +2524,7 @@ hello();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_ziparray1-array2-"></a>`_.zip([array1, array2, ...])`
|
||||
<a href="#_ziparray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1926 "View in source") [Ⓣ][1]
|
||||
<a href="#_ziparray1-array2-">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1955 "View in source") [Ⓣ][1]
|
||||
|
||||
Merges the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion.
|
||||
|
||||
@@ -2516,7 +2548,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_zipobjectkeys"></a>`_.zipObject(keys)`
|
||||
<a href="#_zipobjectkeys">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1955 "View in source") [Ⓣ][1]
|
||||
<a href="#_zipobjectkeys">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1984 "View in source") [Ⓣ][1]
|
||||
|
||||
Merges an array of `keys` and an array of `values` into a single object.
|
||||
|
||||
@@ -2547,7 +2579,7 @@ _.zipObject(['moe', 'larry', 'curly'], [30, 40, 50]);
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_prototypechain"></a>`_.prototype.chain()`
|
||||
<a href="#_prototypechain">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1]
|
||||
<a href="#_prototypechain">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3644 "View in source") [Ⓣ][1]
|
||||
|
||||
Enables method chaining on the wrapper object.
|
||||
|
||||
@@ -2568,7 +2600,7 @@ _([1, 2, 3]).value();
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_prototypevalue"></a>`_.prototype.value()`
|
||||
<a href="#_prototypevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3633 "View in source") [Ⓣ][1]
|
||||
<a href="#_prototypevalue">#</a> [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3661 "View in source") [Ⓣ][1]
|
||||
|
||||
Extracts the wrapped value.
|
||||
|
||||
|
||||
141
lodash.js
141
lodash.js
@@ -391,6 +391,23 @@
|
||||
'inLoop': 'callback(iteratee[index], index, collection)'
|
||||
};
|
||||
|
||||
/** Reusable iterator options for `countBy`, `groupBy`, and `sortBy` */
|
||||
var countByIteratorOptions = {
|
||||
'init': '{}',
|
||||
'top':
|
||||
'var prop;\n' +
|
||||
'if (typeof callback != \'function\') {\n' +
|
||||
' var valueProp = callback;\n' +
|
||||
' callback = function(value) { return value[valueProp] }\n' +
|
||||
'}\n' +
|
||||
'else if (thisArg) {\n' +
|
||||
' callback = iteratorBind(callback, thisArg)\n' +
|
||||
'}',
|
||||
'inLoop':
|
||||
'prop = callback(iteratee[index], index, collection);\n' +
|
||||
'(hasOwnProperty.call(result, prop) ? result[prop]++ : result[prop] = 1)'
|
||||
};
|
||||
|
||||
/** Reusable iterator options for `every` and `some` */
|
||||
var everyIteratorOptions = {
|
||||
'init': 'true',
|
||||
@@ -775,6 +792,34 @@
|
||||
'inLoop': 'if (iteratee[index] === target) return true'
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates an object composed of keys returned from running each element of
|
||||
* `collection` through a `callback`. The corresponding value of each key is
|
||||
* the number of times the key was returned by `callback`. The `callback` is
|
||||
* bound to `thisArg` and invoked with 3 arguments; (value, index|key, collection).
|
||||
* The `callback` argument may also be the name of a property to count by (e.g. 'length').
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Collections
|
||||
* @param {Array|Object|String} collection The collection to iterate over.
|
||||
* @param {Function|String} callback The function called per iteration or
|
||||
* property name to count by.
|
||||
* @param {Mixed} [thisArg] The `this` binding for the callback.
|
||||
* @returns {Object} Returns the composed aggregate object.
|
||||
* @example
|
||||
*
|
||||
* _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
|
||||
* // => { '4': 1, '6': 2 }
|
||||
*
|
||||
* _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
||||
* // => { '4': 1, '6': 2 }
|
||||
*
|
||||
* _.countBy(['one', 'two', 'three'], 'length');
|
||||
* // => { '3': 2, '5': 1 }
|
||||
*/
|
||||
var countBy = createIterator(baseIteratorOptions, countByIteratorOptions);
|
||||
|
||||
/**
|
||||
* Checks if the `callback` returns a truthy value for **all** elements of a
|
||||
* `collection`. The `callback` is bound to `thisArg` and invoked with 3
|
||||
@@ -863,10 +908,11 @@
|
||||
var forEach = createIterator(baseIteratorOptions, forEachIteratorOptions);
|
||||
|
||||
/**
|
||||
* Splits `collection` 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|key, collection). The `callback` argument may
|
||||
* also be the name of a property to group by.
|
||||
* Creates an object composed of keys returned from running each element of
|
||||
* `collection` through a `callback`. The corresponding value of each key is an
|
||||
* array of elements passed to `callback` that returned the key. The `callback`
|
||||
* is bound to `thisArg` and invoked with 3 arguments; (value, index|key, collection).
|
||||
* The `callback` argument may also be the name of a property to count by (e.g. 'length').
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -875,27 +921,21 @@
|
||||
* @param {Function|String} callback The function called per iteration or
|
||||
* property name to group by.
|
||||
* @param {Mixed} [thisArg] The `this` binding for the callback.
|
||||
* @returns {Object} Returns an object of grouped values.
|
||||
* @returns {Object} Returns the composed aggregate object.
|
||||
* @example
|
||||
*
|
||||
* _.groupBy([1.3, 2.1, 2.4], function(num) { return Math.floor(num); });
|
||||
* // => { '1': [1.3], '2': [2.1, 2.4] }
|
||||
* _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
|
||||
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
||||
*
|
||||
* _.groupBy([1.3, 2.1, 2.4], function(num) { return this.floor(num); }, Math);
|
||||
* // => { '1': [1.3], '2': [2.1, 2.4] }
|
||||
* _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
||||
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
||||
*
|
||||
* _.groupBy(['one', 'two', 'three'], 'length');
|
||||
* // => { '3': ['one', 'two'], '5': ['three'] }
|
||||
*/
|
||||
var groupBy = createIterator(baseIteratorOptions, {
|
||||
'init': '{}',
|
||||
'top':
|
||||
'var prop, isFunc = typeof callback == \'function\';\n' +
|
||||
'if (isFunc && thisArg) callback = iteratorBind(callback, thisArg)',
|
||||
var groupBy = createIterator(baseIteratorOptions, countByIteratorOptions, {
|
||||
'inLoop':
|
||||
'prop = isFunc\n' +
|
||||
' ? callback(iteratee[index], index, collection)\n' +
|
||||
' : iteratee[index][callback];\n' +
|
||||
'prop = callback(iteratee[index], index, collection);\n' +
|
||||
'(hasOwnProperty.call(result, prop) ? result[prop] : result[prop] = []).push(iteratee[index])'
|
||||
});
|
||||
|
||||
@@ -937,9 +977,9 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* Produces a new array of values by mapping each element in the `collection`
|
||||
* through a transformation `callback`. The `callback` is bound to `thisArg`
|
||||
* and invoked with 3 arguments; (value, index|key, collection).
|
||||
* Creates a new array of values by running each element in the `collection`
|
||||
* through a `callback`. The `callback` is bound to `thisArg` and invoked with
|
||||
* 3 arguments; (value, index|key, collection).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -1128,13 +1168,11 @@
|
||||
'inLoop': everyIteratorOptions.inLoop.replace('!', '')
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Produces a new sorted array, sorted in ascending order by the results of
|
||||
* running each element of `collection` through a transformation `callback`.
|
||||
* The `callback` is bound to `thisArg` and invoked with 3 arguments;
|
||||
* (value, index|key, collection). The `callback` argument may also be the
|
||||
* name of a property to sort by (e.g. 'length').
|
||||
* Creates a new sorted array, sorted in ascending order by the results of
|
||||
* running each element of `collection` through a `callback`. The `callback` is
|
||||
* bound to `thisArg` and invoked with 3 arguments; (value, index|key, collection).
|
||||
* The `callback` argument may also be the name of a property to sort by (e.g. 'length').
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -1155,15 +1193,7 @@
|
||||
* _.sortBy(['larry', 'brendan', 'moe'], 'length');
|
||||
* // => ['moe', 'larry', 'brendan']
|
||||
*/
|
||||
var sortBy = createIterator(baseIteratorOptions, mapIteratorOptions, {
|
||||
'top':
|
||||
'if (typeof callback == \'string\') {\n' +
|
||||
' var prop = callback;\n' +
|
||||
' callback = function(collection) { return collection[prop] }\n' +
|
||||
'}\n' +
|
||||
'else if (thisArg) {\n' +
|
||||
' callback = iteratorBind(callback, thisArg)\n' +
|
||||
'}',
|
||||
var sortBy = createIterator(baseIteratorOptions, countByIteratorOptions, mapIteratorOptions, {
|
||||
'inLoop': {
|
||||
'array':
|
||||
'result[index] = {\n' +
|
||||
@@ -1217,7 +1247,7 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Produces a new array with all falsey values of `array` removed. The values
|
||||
* Creates a new array with all falsey values of `array` removed. The values
|
||||
* `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
|
||||
*
|
||||
* @static
|
||||
@@ -1247,7 +1277,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a new array of `array` values not present in the other arrays
|
||||
* Creates a new array of `array` values not present in the other arrays
|
||||
* using strict equality for comparisons, i.e. `===`.
|
||||
*
|
||||
* @static
|
||||
@@ -1691,7 +1721,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a new array of shuffled `array` values, using a version of the
|
||||
* Creates a new array of shuffled `array` values, using a version of the
|
||||
* Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
|
||||
*
|
||||
* @static
|
||||
@@ -1811,12 +1841,11 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a duplicate-value-free version of the `array` using strict equality
|
||||
* Creates a duplicate-value-free version of the `array` using strict equality
|
||||
* for comparisons, i.e. `===`. If the `array` is already sorted, passing `true`
|
||||
* for `isSorted` will run a faster algorithm. If `callback` is passed,
|
||||
* each 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).
|
||||
* for `isSorted` will run a faster algorithm. If `callback` is passed, each
|
||||
* element of `array` is passed through a callback` before uniqueness is computed.
|
||||
* The `callback` is bound to `thisArg` and invoked with 3 arguments; (value, index, array).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -1876,7 +1905,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a new array with all occurrences of the passed values removed using
|
||||
* Creates a new array with all occurrences of the passed values removed using
|
||||
* strict equality for comparisons, i.e. `===`.
|
||||
*
|
||||
* @static
|
||||
@@ -2211,7 +2240,7 @@
|
||||
|
||||
/**
|
||||
* Executes the `func` function after `wait` milliseconds. Additional arguments
|
||||
* are passed to `func` when it is invoked.
|
||||
* will be passed to `func` when it is invoked.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -2233,7 +2262,7 @@
|
||||
|
||||
/**
|
||||
* Defers executing the `func` function until the current call stack has cleared.
|
||||
* Additional arguments are passed to `func` when it is invoked.
|
||||
* Additional arguments will be passed to `func` when it is invoked.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -2396,16 +2425,15 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Create a new function that passes `func` to the `wrapper` function as its
|
||||
* first argument. Additional arguments passed to the new function are appended
|
||||
* to those passed to the `wrapper` function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Functions
|
||||
* @param {Function} func The function to wrap.
|
||||
* @param {Function} wrapper The wrapper function.
|
||||
* @param {Mixed} [arg1, arg2, ...] Arguments to append to those passed to the wrapper.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
@@ -2565,7 +2593,7 @@
|
||||
var forOwn = createIterator(baseIteratorOptions, forEachIteratorOptions, forOwnIteratorOptions);
|
||||
|
||||
/**
|
||||
* Produces a sorted array of the enumerable properties, own and inherited,
|
||||
* Creates a sorted array of all enumerable properties, own and inherited,
|
||||
* of `object` that have function values.
|
||||
*
|
||||
* @static
|
||||
@@ -3086,7 +3114,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces an array of object`'s own enumerable property names.
|
||||
* Creates an array composed of the own enumerable property names of `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -3169,7 +3197,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces an array of `object`'s own enumerable property values.
|
||||
* Creates an array composed of the own enumerable property values of `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -3391,8 +3419,8 @@
|
||||
escapeDelimiter = settings.escape;
|
||||
}
|
||||
if (evaluateDelimiter == null) {
|
||||
// use `false` as the fallback value so the initial assignment of
|
||||
// `reEvaluateDelimiter` will still occur
|
||||
// use `false` as the fallback value, instead of leaving it `undefined`,
|
||||
// so the initial assignment of `reEvaluateDelimiter` will still occur
|
||||
evaluateDelimiter = settings.evaluate || false;
|
||||
}
|
||||
if (interpolateDelimiter == null) {
|
||||
@@ -3582,7 +3610,7 @@
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Chaining
|
||||
* @param {Mixed} value The value to pass to `callback`.
|
||||
* @param {Mixed} value The value to pass to `interceptor`.
|
||||
* @param {Function} interceptor The function to invoke.
|
||||
* @returns {Mixed} Returns `value`.
|
||||
* @example
|
||||
@@ -3654,6 +3682,7 @@
|
||||
lodash.compact = compact;
|
||||
lodash.compose = compose;
|
||||
lodash.contains = contains;
|
||||
lodash.countBy = countBy;
|
||||
lodash.debounce = debounce;
|
||||
lodash.defaults = defaults;
|
||||
lodash.defer = defer;
|
||||
|
||||
42
lodash.min.js
vendored
42
lodash.min.js
vendored
@@ -6,30 +6,30 @@
|
||||
("string"==typeof n&&(n={b:n,l:n}),u.c[t]=n.b,u.m[t]=n.l):u[t]=n;e=u.a,t=/^[^,]+/.exec(e)[0],u.g=t,u.h=mt,u.k=wt,u.o=J,u.q=u.q!==i,u.r=u.r!==i,"n"in u||(u.n=yt),u.f||(u.f="if(!"+t+")return G");if("h"!=t||!u.c.i)u.c=r;t="",u.r&&(t+="'use strict';"),t+="var p,s="+u.g+",G",u.j&&(t+="="+u.j),t+=";"+u.f+";"+u.p+";",u.c&&(t+="var v=s.length;p=-1;",u.m&&(t+="if(v===v>>>0){"),u.n&&(t+="if(M.call(s)==J){s=s.split('')}"),t+=u.c.d+";while(++p<v){"+u.c.i+"}",u.m&&(t+="}"));if(u.m){u.c&&(t+="else{"),u.h||(t+="var H=typeof s=='function'&&F.call(s,'prototype');"
|
||||
),u.k&&u.q?t+="var D=x(s),C=-1,v=D.length;"+u.m.d+";while(++C<v){p=D[C];if(!(H&&p=='prototype')){"+u.m.i+"}}":(t+=u.m.d+";for(p in s){",u.h?(u.q&&(t+="if(n.call(s,p)){"),t+=u.m.i+";",u.q&&(t+="}")):(t+="if(!(H&&p=='prototype')",u.q&&(t+="&&n.call(s,p)"),t+="){"+u.m.i+"}"),t+="}");if(u.h){t+="var k=s.constructor;";for(n=0;7>n;n++)t+="p='"+u.o[n]+"';if(","constructor"==u.o[n]&&(t+="!(k&&k.prototype===s)&&"),t+="n.call(s,p)){"+u.m.i+"}"}u.c&&(t+="}")}return t+=u.e+";return G",Function("c,d,e,i,j,l,n,o,q,u,A,x,F,I,J,M"
|
||||
,"return function("+e+"){"+t+"}")(ut,H,C,f,G,lt,Y,L,E,p,St,ot,et,tt,pt,nt)}function f(e,n){return e=e.a,n=n.a,e===t?1:n===t?-1:e<n?-1:e>n?1:0}function l(e,t){return Q[t]}function c(e){return"\\"+xt[e]}function h(e){return Et[e]}function p(e,t){return function(n,r,i){return e.call(t,n,r,i)}}function d(){}function v(e,t){if(I.test(t))return"<e%-"+t+"%>";var n=Q.length;return Q[n]="'+__e("+t+")+'",K+n}function m(e,t,n,r){return e=Q.length,t?Q[e]="'+__e("+t+")+'":r?Q[e]="';"+r+";__p+='":n&&(Q[e]="'+((__t=("+
|
||||
n+"))==null?'':__t)+'"),K+e}function g(e,t){if(I.test(t))return"<e%="+t+"%>";var n=Q.length;return Q[n]="'+((__t=("+t+"))==null?'':__t)+'",K+n}function y(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=p(t,r));if(i===i>>>0){var o=yt&&nt.call(e)==pt?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=en(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function b(e,t,n){if(e)return t==r||n?e[0]:tt.call(e,0,t)}function w(e,t){var n=[];if(!e)
|
||||
return n;for(var r,i=-1,s=e.length;++i<s;)r=e[i],Yt(r)?Z.apply(n,t?r:w(r)):n.push(r);return n}function E(e,t,n){if(!e)return-1;var r=-1,i=e.length;if(n){if("number"!=typeof n)return r=T(e,t),e[r]===t?r:-1;r=(0>n?Math.max(0,i+n):n)-1}for(;++r<i;)if(e[r]===t)return r;return-1}function S(e,t,n){var r=-Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]>i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n>r&&(r=n,i=e[s]);return i}function x(e,t,n){return e?tt.call(e,t==r||
|
||||
n+"))==null?'':__t)+'"),K+e}function g(e,t){if(I.test(t))return"<e%="+t+"%>";var n=Q.length;return Q[n]="'+((__t=("+t+"))==null?'':__t)+'",K+n}function y(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=p(t,r));if(i===i>>>0){var o=yt&&nt.call(e)==pt?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=nn(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function b(e,t,n){if(e)return t==r||n?e[0]:tt.call(e,0,t)}function w(e,t){var n=[];if(!e)
|
||||
return n;for(var r,i=-1,s=e.length;++i<s;)r=e[i],en(r)?Z.apply(n,t?r:w(r)):n.push(r);return n}function E(e,t,n){if(!e)return-1;var r=-1,i=e.length;if(n){if("number"!=typeof n)return r=T(e,t),e[r]===t?r:-1;r=(0>n?Math.max(0,i+n):n)-1}for(;++r<i;)if(e[r]===t)return r;return-1}function S(e,t,n){var r=-Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]>i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n>r&&(r=n,i=e[s]);return i}function x(e,t,n){return e?tt.call(e,t==r||
|
||||
n?1:t):[]}function T(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=C(n,r));for(t=n(t);i<s;)r=i+s>>>1,n(e[r])<t?i=r+1:s=r}else for(;i<s;)r=i+s>>>1,e[r]<t?i=r+1:s=r;return i}function N(e,t,n,r){var s=[];if(!e)return s;var o=-1,u=e.length,a=[];"function"==typeof t&&(r=n,n=t,t=i);for(n?r&&(n=p(n,r)):n=L;++o<u;)if(r=n(e[o],o,e),t?!o||a[a.length-1]!==r:0>E(a,r))a.push(r),s.push(e[o]);return s}function C(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length?G.apply(s,o)
|
||||
:s),this instanceof n?(d.prototype=e.prototype,u=new d,(o=e.apply(u,o))&&St[typeof o]?o:u):e.apply(u,o)}var r,i=nt.call(e)==lt;if(i){if(bt||rt&&2<arguments.length)return rt.call.apply(rt,arguments)}else r=t,t=e;var s=tt.call(arguments,2);return n}function k(e,t,s){s||(s=[]);if(e===t)return 0!==e||1/e==1/t;if(e==r||t==r)return e===t;e._chain&&(e=e._wrapped),t._chain&&(t=t._wrapped);if(e.isEqual&&nt.call(e.isEqual)==lt)return e.isEqual(t);if(t.isEqual&&nt.call(t.isEqual)==lt)return t.isEqual(e);var o=
|
||||
nt.call(e);if(o!=nt.call(t))return i;switch(o){case pt:return e==""+t;case ct:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case at:case ft:return+e==+t;case ht:return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)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==ut){if(f=e.length,a=f==t.length)for(;f--&&(a=k(e[f],t[f],s)););}else{if("constructor"in e!="constructor"in t||e.constructor!=
|
||||
t.constructor)return i;for(var l in e)if(Y.call(e,l)&&(f++,!(a=Y.call(t,l)&&k(e[l],t[l],s))))break;if(a){for(l in t)if(Y.call(t,l)&&!(f--))break;a=!f}if(a&&mt)for(;7>++u&&(l=J[u],!Y.call(e,l)||!!(a=Y.call(t,l)&&k(e[l],t[l],s))););}return s.pop(),a}function L(e){return e}function A(e){Bt(Gt(e),function(t){var r=s[t]=e[t];o.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&Z.apply(e,arguments),e=r.apply(s,e),this._chain&&(e=new o(e),e._chain=n),e}})}var n=!0,r=null,i=!1,O,M,_,D
|
||||
t.constructor)return i;for(var l in e)if(Y.call(e,l)&&(f++,!(a=Y.call(t,l)&&k(e[l],t[l],s))))break;if(a){for(l in t)if(Y.call(t,l)&&!(f--))break;a=!f}if(a&&mt)for(;7>++u&&(l=J[u],!Y.call(e,l)||!!(a=Y.call(t,l)&&k(e[l],t[l],s))););}return s.pop(),a}function L(e){return e}function A(e){Ft(Zt(e),function(t){var r=s[t]=e[t];o.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&Z.apply(e,arguments),e=r.apply(s,e),this._chain&&(e=new o(e),e._chain=n),e}})}var n=!0,r=null,i=!1,O,M,_,D
|
||||
,P="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(e=global),exports),H=Array.prototype,B=Object.prototype,j=0,F=e._,I=/[-+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,q=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,U=/(__e\(.*?\)|\b__t\))\+'';/g,z=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,W=RegExp("^"+(B.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),X=/__token__(\d+)/g,V=/[&<"']/g,$=/['\n\r\t\u2028\u2029\\]/g
|
||||
,J="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),K="__token__",Q=[],G=H.concat,Y=B.hasOwnProperty,Z=H.push,et=B.propertyIsEnumerable,tt=H.slice,nt=B.toString,rt=W.test(rt=tt.bind)&&rt,it=W.test(it=Array.isArray)&&it,st=e.isFinite,ot=W.test(ot=Object.keys)&&ot,ut="[object Array]",at="[object Boolean]",ft="[object Date]",lt="[object Function]",ct="[object Number]",ht="[object RegExp]",pt="[object String]",dt=e.clearTimeout,vt=e.setTimeout
|
||||
,mt=!et.call({valueOf:0},"valueOf"),gt="x"!=tt.call("x")[0],yt="xx"!="x"[0]+Object("x")[0],bt=rt&&/\n|Opera/.test(rt+nt.call(e.opera)),wt=ot&&/^.+$|true/.test(ot+!!e.attachEvent),Et={"&":"&","<":"<",'"':""","'":"'"},St={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},xt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"
|
||||
};var Tt={a:"h,f,L",j:"h",p:"if(!f){f=o}else if(L)f=u(f,L)",i:"f(s[p],p,h)"},Nt={j:"true",i:"if(!f(s[p],p,h))return!G"},Ct={q:i,r:i,a:"z",j:"z",p:"for(var t=1,v=arguments.length;t<v;t++){s=arguments[t];"+(mt?"if(s){":""),i:"G[p]=s[p]",e:(mt?"}":"")+"}"},kt={j:"[]",i:"f(s[p],p,h)&&G.push(s[p])"},Lt={p:"if(L)f=u(f,L)"},At={i:{l:Tt.i}},Ot={j:"",f:"if(!h)return[]",d:{b:"G=Array(v)",l:"G="+(wt?"Array(v)":"[]")},i:{b:"G[p]=f(s[p],p,h)",l:"G"+(wt?"[C]=":".push")+"(f(s[p],p,h))"}},Mt=a({a:"z",f:"if(!(z&&A[typeof z]))throw TypeError()"
|
||||
,j:"[]",i:"G.push(p)"}),_t=a({a:"h,K",j:"false",n:i,d:{b:"if(M.call(s)==J)return h.indexOf(K)>-1"},i:"if(s[p]===K)return true"}),Dt=a(Tt,Nt),Pt=a(Tt,kt),Ht=a(Tt,Lt,{j:"",i:"if(f(s[p],p,h))return s[p]"}),Bt=a(Tt,Lt),jt=a(Tt,{j:"{}",p:"var B,r=typeof f=='function';if(r&&L)f=u(f,L)",i:"B=r?f(s[p],p,h):s[p][f];(n.call(G,B)?G[B]:G[B]=[]).push(s[p])"}),Ft=a(Ot,{a:"h,w",p:"var b=I.call(arguments,2),r=typeof w=='function'",i:{b:"G[p]=(r?w:s[p][w]).apply(s[p],b)",l:"G"+(wt?"[C]=":".push")+"((r?w:s[p][w]).apply(s[p],b))"
|
||||
}}),It=a(Tt,Ot),qt=a(Ot,{a:"h,E",i:{b:"G[p]=s[p][E]",l:"G"+(wt?"[C]=":".push")+"(s[p][E])"}}),Rt=a({a:"h,f,a,L",j:"a",p:"var y=arguments.length<3;if(L)f=u(f,L)",d:{b:"if(y)G=h[++p]"},i:{b:"G=f(G,s[p],p,h)",l:"G=y?(y=false,s[p]):f(G,s[p],p,h)"}}),Ut=a(Tt,kt,{i:"!"+kt.i}),zt=a(Tt,Nt,{j:"false",i:Nt.i.replace("!","")}),Wt=a(Tt,Ot,{p:"if(typeof f=='string'){var B=f;f=function(h){return h[B]}}else if(L)f=u(f,L)",i:{b:"G[p]={a:f(s[p],p,h),b:s[p]}",l:"G"+(wt?"[C]=":".push")+"({a:f(s[p],p,h),b:s[p]})"},e
|
||||
:"G.sort(i);v=G.length;while(v--){G[v]=G[v].b}"}),Xt=a({q:i,r:i,a:"z",j:"z",p:"var m=arguments,v=m.length;if(v>1){for(var p=1;p<v;p++)G[m[p]]=e(G[m[p]],G);return G}",i:"if(M.call(G[p])==l)G[p]=e(G[p],G)"}),Vt=a(Ct,{i:"if(G[p]==null)"+Ct.i}),$t=a({q:i,a:"z",j:"{}",p:"var D=j.apply(d,arguments)",i:"if(q(D,p)<0)G[p]=s[p]"}),Jt=a(Ct),Kt=a(Tt,Lt,At,{q:i}),Qt=a(Tt,Lt,At),Gt=a({q:i,a:"z",j:"[]",i:"if(M.call(s[p])==l)G.push(p)",e:"G.sort()"});Bt({Arguments:"[object Arguments]",Date:ft,Function:lt,Number:
|
||||
ct,RegExp:ht,String:pt},function(e,t){s["is"+t]=function(t){return nt.call(t)==e}}),s.isArguments(arguments)||(s.isArguments=function(e){return!!e&&!!Y.call(e,"callee")});var Yt=it||function(e){return nt.call(e)==ut},Zt=a({a:"N",j:"true",p:"var g=M.call(N);if(g==c||g==J)return!N.length",i:{l:"return false"}}),en=ot?function(e){return"function"==typeof e&&et.call(e,"prototype")?Mt(e):ot(e)}:Mt,tn=a({a:"z",j:"[]",i:"G.push(s[p])"});s.VERSION="0.4.2",s.after=function(e,t){return 1>e?t():function(){if(1>--
|
||||
e)return t.apply(this,arguments)}},s.bind=C,s.bindAll=Xt,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=function(e){return e&&St[typeof e]?Yt(e)?e.slice():Jt({},e):e},s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++n<r;)e[n]&&t.push(e[n]);return t},s.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},s.contains=_t,s.debounce=function(e,t,n){function i(){a=r,n||e.apply(u,s)}var s,o,u,a;return function(
|
||||
){var r=n&&!a;return s=arguments,u=this,dt(a),a=vt(i,t),r&&(o=e.apply(u,s)),o}},s.defaults=Vt,s.defer=function(e){var n=tt.call(arguments,1);return vt(function(){return e.apply(t,n)},1)},s.delay=function(e,n){var r=tt.call(arguments,2);return vt(function(){return e.apply(t,r)},n)},s.difference=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=G.apply(t,arguments),i=u(i,r);++n<r;)i(e[n])||t.push(e[n]);return t},s.drop=$t,s.escape=function(e){return e==r?"":(e+"").replace(V,h)},s.every=
|
||||
Dt,s.extend=Jt,s.filter=Pt,s.find=Ht,s.first=b,s.flatten=w,s.forEach=Bt,s.forIn=Kt,s.forOwn=Qt,s.functions=Gt,s.groupBy=jt,s.has=function(e,t){return Y.call(e,t)},s.identity=L,s.indexOf=E,s.initial=function(e,t,n){return e?tt.call(e,0,-(t==r||n?1:t)):[]},s.intersection=function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=tt.call(arguments,1),o=[];++r<i;)n=e[r],0>E(t,n)&&Dt(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke=Ft,s.isArray=Yt,s.isBoolean=function(
|
||||
e){return e===n||e===i||nt.call(e)==at},s.isElement=function(e){return!!e&&1==e.nodeType},s.isEmpty=Zt,s.isEqual=k,s.isFinite=function(e){return st(e)&&nt.call(e)==ct},s.isNaN=function(e){return nt.call(e)==ct&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e&&St[typeof e]},s.isUndefined=function(e){return e===t},s.keys=en,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:tt.call(e,-t||i)}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof
|
||||
n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=It,s.max=S,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Y.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]<i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n<r&&(r=n,i=e[s]);return i},s.mixin=A,s.noConflict=function(){return e._=F,this},s.once=function(
|
||||
e){var t,r=i;return function(){return r?t:(r=n,t=e.apply(this,arguments))}},s.partial=function(e){var t=tt.call(arguments,1),n=t.length;return function(){var r;return r=arguments,r.length&&(t.length=n,Z.apply(t,r)),r=1==t.length?e.call(this,t[0]):e.apply(this,t),t.length=n,r}},s.pick=function(e){for(var t,n=0,r=G.apply(H,arguments),i=r.length,s={};++n<i;)t=r[n],t in e&&(s[t]=e[t]);return s},s.pluck=qt,s.range=function(e,t,n){n||(n=1),t==r&&(t=e||0,e=0);for(var i=-1,t=Math.max(0,Math.ceil((t-e)/n)
|
||||
),s=Array(t);++i<t;)s[i]=e,e+=n;return s},s.reduce=Rt,s.reduceRight=y,s.reject=Ut,s.rest=x,s.result=function(e,t){if(!e)return r;var n=e[t];return nt.call(n)==lt?e[t]():n},s.shuffle=function(e){if(!e)return[];for(var t,n=-1,r=e.length,i=Array(r);++n<r;)t=Math.floor(Math.random()*(n+1)),i[n]=i[t],i[t]=e[n];return i},s.size=function(e){if(!e)return 0;var t=e.length;return t===t>>>0?e.length:en(e).length},s.some=zt,s.sortBy=Wt,s.sortedIndex=T,s.tap=function(e,t){return t(e),e},s.template=function(e,
|
||||
t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,n=n.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,v)),f&&(e=e.replace(f,g)),a!=O&&(O=a,D=RegExp("<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>"+(a?"|"+a.source:""),"g")),o=Q.length,e=e.replace(D,m),o=o!=Q.length,e="__p += '"+e.replace($,c).replace(X,l)+"';",Q.length=0,n||(n=h.variable||M||"obj",o?e="with("+n+"){"+e+"}":(n!=M&&(M=n,_=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g"
|
||||
)),e=e.replace(z,"$&"+n+".").replace(_,"$1__d"))),e=(o?e.replace(q,""):e).replace(R,"$1").replace(U,"$1;"),e="function("+n+"){"+n+"||("+n+"={});var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":",__d="+n+"."+n+"||"+n+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(p){u=function(){throw p}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date
|
||||
,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=vt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r<e;)t.call(n,r);else for(;++r<e;)t(r)},s.toArray=function(e){if(!e)return[];if(e.toArray&&nt.call(e.toArray)==lt)return e.toArray();var t=e.length;return t===t>>>0?(gt?nt.call(e)==pt:"string"==typeof e)?e.split(""):tt.call(e):tn(e)},s.union=function(){for(var e=-1,t=[],n=G.apply(t,arguments),r=n.length;++e<r;)0>E(t,n[e])&&t.push(n[e]);return t},s.uniq=N,s.uniqueId=function(
|
||||
e){var t=j++;return e?e+t:t},s.values=tn,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n<r;)i(e[n])||t.push(e[n]);return t},s.wrap=function(e,t){return function(){var n=[e];return arguments.length&&Z.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=S(qt(arguments,"length")),r=Array(n);++t<n;)r[t]=qt(arguments,t);return r},s.zipObject=function(e,t){if(!e)return{};var n=-1,r=e.length,i={};for(t||(t=[]);++n<r;)i[e[n]]=
|
||||
t[n];return i},s.all=Dt,s.any=zt,s.collect=It,s.detect=Ht,s.each=Bt,s.foldl=Rt,s.foldr=y,s.head=b,s.include=_t,s.inject=Rt,s.methods=Gt,s.select=Pt,s.tail=x,s.take=b,s.unique=N,o.prototype=s.prototype,A(s),o.prototype.chain=function(){return this._chain=n,this},o.prototype.value=function(){return this._wrapped},Bt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=H[e];o.prototype[e]=function(){var e=this._wrapped;return t.apply(e,arguments),e.length===0&&delete e[0],this._chain&&
|
||||
(e=new o(e),e._chain=n),e}}),Bt(["concat","join","slice"],function(e){var t=H[e];o.prototype[e]=function(){var e=t.apply(this._wrapped,arguments);return this._chain&&(e=new o(e),e._chain=n),e}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):P?"object"==typeof module&&module&&module.s==P?(module.s=s)._=s:P._=s:e._=s})(this);
|
||||
};var Tt={a:"h,f,L",j:"h",p:"if(!f){f=o}else if(L)f=u(f,L)",i:"f(s[p],p,h)"},Nt={j:"{}",p:"var B;if(typeof f!='function'){var O=f;f=function(N){return N[O]}}else if(L)f=u(f,L)",i:"B=f(s[p],p,h);(n.call(G,B)?G[B]++:G[B]=1)"},Ct={j:"true",i:"if(!f(s[p],p,h))return!G"},kt={q:i,r:i,a:"z",j:"z",p:"for(var t=1,v=arguments.length;t<v;t++){s=arguments[t];"+(mt?"if(s){":""),i:"G[p]=s[p]",e:(mt?"}":"")+"}"},Lt={j:"[]",i:"f(s[p],p,h)&&G.push(s[p])"},At={p:"if(L)f=u(f,L)"},Ot={i:{l:Tt.i}},Mt={j:"",f:"if(!h)return[]"
|
||||
,d:{b:"G=Array(v)",l:"G="+(wt?"Array(v)":"[]")},i:{b:"G[p]=f(s[p],p,h)",l:"G"+(wt?"[C]=":".push")+"(f(s[p],p,h))"}},_t=a({a:"z",f:"if(!(z&&A[typeof z]))throw TypeError()",j:"[]",i:"G.push(p)"}),Dt=a({a:"h,K",j:"false",n:i,d:{b:"if(M.call(s)==J)return h.indexOf(K)>-1"},i:"if(s[p]===K)return true"}),Pt=a(Tt,Nt),Ht=a(Tt,Ct),Bt=a(Tt,Lt),jt=a(Tt,At,{j:"",i:"if(f(s[p],p,h))return s[p]"}),Ft=a(Tt,At),It=a(Tt,Nt,{i:"B=f(s[p],p,h);(n.call(G,B)?G[B]:G[B]=[]).push(s[p])"}),qt=a(Mt,{a:"h,w",p:"var b=I.call(arguments,2),r=typeof w=='function'"
|
||||
,i:{b:"G[p]=(r?w:s[p][w]).apply(s[p],b)",l:"G"+(wt?"[C]=":".push")+"((r?w:s[p][w]).apply(s[p],b))"}}),Rt=a(Tt,Mt),Ut=a(Mt,{a:"h,E",i:{b:"G[p]=s[p][E]",l:"G"+(wt?"[C]=":".push")+"(s[p][E])"}}),zt=a({a:"h,f,a,L",j:"a",p:"var y=arguments.length<3;if(L)f=u(f,L)",d:{b:"if(y)G=h[++p]"},i:{b:"G=f(G,s[p],p,h)",l:"G=y?(y=false,s[p]):f(G,s[p],p,h)"}}),Wt=a(Tt,Lt,{i:"!"+Lt.i}),Xt=a(Tt,Ct,{j:"false",i:Ct.i.replace("!","")}),Vt=a(Tt,Nt,Mt,{i:{b:"G[p]={a:f(s[p],p,h),b:s[p]}",l:"G"+(wt?"[C]=":".push")+"({a:f(s[p],p,h),b:s[p]})"
|
||||
},e:"G.sort(i);v=G.length;while(v--){G[v]=G[v].b}"}),$t=a({q:i,r:i,a:"z",j:"z",p:"var m=arguments,v=m.length;if(v>1){for(var p=1;p<v;p++)G[m[p]]=e(G[m[p]],G);return G}",i:"if(M.call(G[p])==l)G[p]=e(G[p],G)"}),Jt=a(kt,{i:"if(G[p]==null)"+kt.i}),Kt=a({q:i,a:"z",j:"{}",p:"var D=j.apply(d,arguments)",i:"if(q(D,p)<0)G[p]=s[p]"}),Qt=a(kt),Gt=a(Tt,At,Ot,{q:i}),Yt=a(Tt,At,Ot),Zt=a({q:i,a:"z",j:"[]",i:"if(M.call(s[p])==l)G.push(p)",e:"G.sort()"});Ft({Arguments:"[object Arguments]",Date:ft,Function:lt,Number
|
||||
:ct,RegExp:ht,String:pt},function(e,t){s["is"+t]=function(t){return nt.call(t)==e}}),s.isArguments(arguments)||(s.isArguments=function(e){return!!e&&!!Y.call(e,"callee")});var en=it||function(e){return nt.call(e)==ut},tn=a({a:"N",j:"true",p:"var g=M.call(N);if(g==c||g==J)return!N.length",i:{l:"return false"}}),nn=ot?function(e){return"function"==typeof e&&et.call(e,"prototype")?_t(e):ot(e)}:_t,rn=a({a:"z",j:"[]",i:"G.push(s[p])"});s.VERSION="0.4.2",s.after=function(e,t){return 1>e?t():function(){
|
||||
if(1>--e)return t.apply(this,arguments)}},s.bind=C,s.bindAll=$t,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=function(e){return e&&St[typeof e]?en(e)?e.slice():Qt({},e):e},s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++n<r;)e[n]&&t.push(e[n]);return t},s.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},s.contains=Dt,s.countBy=Pt,s.debounce=function(e,t,n){function i(){a=r,n||e.apply
|
||||
(u,s)}var s,o,u,a;return function(){var r=n&&!a;return s=arguments,u=this,dt(a),a=vt(i,t),r&&(o=e.apply(u,s)),o}},s.defaults=Jt,s.defer=function(e){var n=tt.call(arguments,1);return vt(function(){return e.apply(t,n)},1)},s.delay=function(e,n){var r=tt.call(arguments,2);return vt(function(){return e.apply(t,r)},n)},s.difference=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=G.apply(t,arguments),i=u(i,r);++n<r;)i(e[n])||t.push(e[n]);return t},s.drop=Kt,s.escape=function(e){return e==
|
||||
r?"":(e+"").replace(V,h)},s.every=Ht,s.extend=Qt,s.filter=Bt,s.find=jt,s.first=b,s.flatten=w,s.forEach=Ft,s.forIn=Gt,s.forOwn=Yt,s.functions=Zt,s.groupBy=It,s.has=function(e,t){return Y.call(e,t)},s.identity=L,s.indexOf=E,s.initial=function(e,t,n){return e?tt.call(e,0,-(t==r||n?1:t)):[]},s.intersection=function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=tt.call(arguments,1),o=[];++r<i;)n=e[r],0>E(t,n)&&Ht(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke=qt,
|
||||
s.isArray=en,s.isBoolean=function(e){return e===n||e===i||nt.call(e)==at},s.isElement=function(e){return!!e&&1==e.nodeType},s.isEmpty=tn,s.isEqual=k,s.isFinite=function(e){return st(e)&&nt.call(e)==ct},s.isNaN=function(e){return nt.call(e)==ct&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e&&St[typeof e]},s.isUndefined=function(e){return e===t},s.keys=nn,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:tt.call(e,-t||i)}},s.lastIndexOf=function(e,t,n){if(!
|
||||
e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=Rt,s.max=S,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Y.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]<i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n<r&&(r=n,i=e[s]);return i},s.mixin=A,s.
|
||||
noConflict=function(){return e._=F,this},s.once=function(e){var t,r=i;return function(){return r?t:(r=n,t=e.apply(this,arguments))}},s.partial=function(e){var t=tt.call(arguments,1),n=t.length;return function(){var r;return r=arguments,r.length&&(t.length=n,Z.apply(t,r)),r=1==t.length?e.call(this,t[0]):e.apply(this,t),t.length=n,r}},s.pick=function(e){for(var t,n=0,r=G.apply(H,arguments),i=r.length,s={};++n<i;)t=r[n],t in e&&(s[t]=e[t]);return s},s.pluck=Ut,s.range=function(e,t,n){n||(n=1),t==r&&
|
||||
(t=e||0,e=0);for(var i=-1,t=Math.max(0,Math.ceil((t-e)/n)),s=Array(t);++i<t;)s[i]=e,e+=n;return s},s.reduce=zt,s.reduceRight=y,s.reject=Wt,s.rest=x,s.result=function(e,t){if(!e)return r;var n=e[t];return nt.call(n)==lt?e[t]():n},s.shuffle=function(e){if(!e)return[];for(var t,n=-1,r=e.length,i=Array(r);++n<r;)t=Math.floor(Math.random()*(n+1)),i[n]=i[t],i[t]=e[n];return i},s.size=function(e){if(!e)return 0;var t=e.length;return t===t>>>0?e.length:nn(e).length},s.some=Xt,s.sortBy=Vt,s.sortedIndex=T,
|
||||
s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,n=n.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,v)),f&&(e=e.replace(f,g)),a!=O&&(O=a,D=RegExp("<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>"+(a?"|"+a.source:""),"g")),o=Q.length,e=e.replace(D,m),o=o!=Q.length,e="__p += '"+e.replace($,c).replace(X,l)+"';",Q.length=0,n||(n=h.variable||M||"obj",o?e="with("+n+"){"+e+"}"
|
||||
:(n!=M&&(M=n,_=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(z,"$&"+n+".").replace(_,"$1__d"))),e=(o?e.replace(q,""):e).replace(R,"$1").replace(U,"$1;"),e="function("+n+"){"+n+"||("+n+"={});var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":",__d="+n+"."+n+"||"+n+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(p){u=function(){throw p}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply
|
||||
(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=vt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r<e;)t.call(n,r);else for(;++r<e;)t(r)},s.toArray=function(e){if(!e)return[];if(e.toArray&&nt.call(e.toArray)==lt)return e.toArray();var t=e.length;return t===t>>>0?(gt?nt.call(e)==pt:"string"==typeof e)?e.split(""):tt.call(e):rn(e)},s.union=function(){for(var e=-1,t=[],n=G.apply(t,arguments),r=n.length;++e<r;)0>E(t,n[
|
||||
e])&&t.push(n[e]);return t},s.uniq=N,s.uniqueId=function(e){var t=j++;return e?e+t:t},s.values=rn,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n<r;)i(e[n])||t.push(e[n]);return t},s.wrap=function(e,t){return function(){var n=[e];return arguments.length&&Z.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=S(Ut(arguments,"length")),r=Array(n);++t<n;)r[t]=Ut(arguments,t);return r},s.zipObject=function(e,t){if(!e)return{
|
||||
};var n=-1,r=e.length,i={};for(t||(t=[]);++n<r;)i[e[n]]=t[n];return i},s.all=Ht,s.any=Xt,s.collect=Rt,s.detect=jt,s.each=Ft,s.foldl=zt,s.foldr=y,s.head=b,s.include=Dt,s.inject=zt,s.methods=Zt,s.select=Bt,s.tail=x,s.take=b,s.unique=N,o.prototype=s.prototype,A(s),o.prototype.chain=function(){return this._chain=n,this},o.prototype.value=function(){return this._wrapped},Ft("pop push reverse shift sort splice unshift".split(" "),function(e){var t=H[e];o.prototype[e]=function(){var e=this._wrapped;return t
|
||||
.apply(e,arguments),e.length===0&&delete e[0],this._chain&&(e=new o(e),e._chain=n),e}}),Ft(["concat","join","slice"],function(e){var t=H[e];o.prototype[e]=function(){var e=t.apply(this._wrapped,arguments);return this._chain&&(e=new o(e),e._chain=n),e}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):P?"object"==typeof module&&module&&module.s==P?(module.s=s)._=s:P._=s:e._=s})(this);
|
||||
62
perf/perf.js
62
perf/perf.js
@@ -136,7 +136,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof groupBy != 'undefined') {
|
||||
if (typeof countBy != 'undefined') {
|
||||
var wordToNumber = {
|
||||
'one': 1,
|
||||
'two': 2,
|
||||
@@ -515,6 +515,50 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.countBy` with `callback` iterating an array')
|
||||
.add('Lo-Dash', function() {
|
||||
lodash.countBy(numbers, function(num) { return num >> 1; });
|
||||
})
|
||||
.add('Underscore', function() {
|
||||
_.countBy(numbers, function(num) { return num >> 1; });
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.countBy` with `property` name iterating an array')
|
||||
.add('Lo-Dash', {
|
||||
'fn': function() {
|
||||
lodash.countBy(words, 'length');
|
||||
},
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add('Underscore', {
|
||||
'fn': function() {
|
||||
_.countBy(words, 'length');
|
||||
},
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.countBy` with `callback` iterating an object')
|
||||
.add('Lo-Dash', {
|
||||
'fn': function() {
|
||||
lodash.countBy(wordToNumber, function(num) { return num >> 1; });
|
||||
},
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add('Underscore', {
|
||||
'fn': function() {
|
||||
_.countBy(wordToNumber, function(num) { return num >> 1; });
|
||||
},
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.difference`')
|
||||
.add('Lo-Dash', function() {
|
||||
@@ -749,13 +793,13 @@
|
||||
'fn': function() {
|
||||
lodash.groupBy(words, 'length');
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add('Underscore', {
|
||||
'fn': function() {
|
||||
_.groupBy(words, 'length');
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
@@ -765,13 +809,13 @@
|
||||
'fn': function() {
|
||||
lodash.groupBy(wordToNumber, function(num) { return num >> 1; });
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add('Underscore', {
|
||||
'fn': function() {
|
||||
_.groupBy(wordToNumber, function(num) { return num >> 1; });
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1149,13 +1193,13 @@
|
||||
'fn': function() {
|
||||
lodash.sortBy(words, 'length');
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add('Underscore', {
|
||||
'fn': function() {
|
||||
_.sortBy(words, 'length');
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1179,7 +1223,7 @@
|
||||
return wordToNumber[value];
|
||||
});
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add('Underscore', {
|
||||
'fn': function() {
|
||||
@@ -1187,7 +1231,7 @@
|
||||
return wordToNumber[value];
|
||||
});
|
||||
},
|
||||
'teardown': 'function groupBy(){}'
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
31
test/test.js
31
test/test.js
@@ -169,6 +169,21 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.countBy');
|
||||
|
||||
(function() {
|
||||
test('should only add elements to own, not inherited, properties', function() {
|
||||
var actual = _.countBy([4.2, 6.1, 6.4], function(num) {
|
||||
return Math.floor(num) > 4 ? 'hasOwnProperty' : 'constructor';
|
||||
});
|
||||
|
||||
deepEqual(actual.constructor, 1);
|
||||
deepEqual(actual.hasOwnProperty, 2);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.debounce');
|
||||
|
||||
(function() {
|
||||
@@ -443,28 +458,28 @@
|
||||
|
||||
(function() {
|
||||
test('supports the `thisArg` argument', function() {
|
||||
var actual = _.groupBy([1.3, 2.1, 2.4], function(num) {
|
||||
var actual = _.groupBy([4.2, 6.1, 6.4], function(num) {
|
||||
return this.floor(num);
|
||||
}, Math);
|
||||
|
||||
deepEqual(actual, { '1': [1.3], '2': [2.1, 2.4] });
|
||||
deepEqual(actual, { '4': [4.2], '6': [6.1, 6.4] });
|
||||
});
|
||||
|
||||
test('should only add elements to own, not inherited, properties', function() {
|
||||
var actual = _.groupBy([1.3, 2.1, 2.4], function(num) {
|
||||
return Math.floor(num) > 1 ? 'hasOwnProperty' : 'constructor';
|
||||
var actual = _.groupBy([4.2, 6.1, 6.4], function(num) {
|
||||
return Math.floor(num) > 4 ? 'hasOwnProperty' : 'constructor';
|
||||
});
|
||||
|
||||
deepEqual(actual.constructor, [1.3]);
|
||||
deepEqual(actual.hasOwnProperty, [2.1, 2.4]);
|
||||
deepEqual(actual.constructor, [4.2]);
|
||||
deepEqual(actual.hasOwnProperty, [6.1, 6.4]);
|
||||
});
|
||||
|
||||
test('should work with an object for `collection`', function() {
|
||||
var actual = _.groupBy({ 'a': 1.3, 'b': 2.1, 'c': 2.4 }, function(num) {
|
||||
var actual = _.groupBy({ 'a': 4.2, 'b': 6.1, 'c': 6.4 }, function(num) {
|
||||
return Math.floor(num);
|
||||
});
|
||||
|
||||
deepEqual(actual, { '1': [1.3], '2': [2.1, 2.4] });
|
||||
deepEqual(actual, { '4': [4.2], '6': [6.1, 6.4] });
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user