mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
lodash: Cleanup documentation. [jddalton]
Former-commit-id: 8fc7693bba4762d337bfe33d389912d37089832c
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// set the version
|
||||
license = license.replace('@VERSION', /VERSION=([\'"])(.*?)\1/.exec(src).pop());
|
||||
license = license.replace('@VERSION', /VERSION:([\'"])(.*?)\1/.exec(src).pop());
|
||||
|
||||
// move vars exposed by Closure Compiler into the IIFE
|
||||
src = src.replace(/^([^(\n]+)\s*(\(function[^)]+\){)/, '$2$1');
|
||||
|
||||
@@ -77,7 +77,6 @@
|
||||
/** Used protect the specified properties from getting minified */
|
||||
var propWhitelist = [
|
||||
'_',
|
||||
'VERSION',
|
||||
'amd',
|
||||
'chain',
|
||||
'clearInterval',
|
||||
|
||||
356
doc/README.md
356
doc/README.md
@@ -12,6 +12,7 @@
|
||||
* [`_.bind`](#_.bind)
|
||||
* [`_.bindAll`](#_.bindAll)
|
||||
* [`_.chain`](#_.chain)
|
||||
* [`_.chain`](#_.chain)
|
||||
* [`_.clone`](#_.clone)
|
||||
* [`_.compact`](#_.compact)
|
||||
* [`_.compose`](#_.compose)
|
||||
@@ -84,6 +85,7 @@
|
||||
* [`_.union`](#_.union)
|
||||
* [`_.uniq`](#_.uniq)
|
||||
* [`_.uniqueId`](#_.uniqueId)
|
||||
* [`_.value`](#_.value)
|
||||
* [`_.values`](#_.values)
|
||||
* [`_.without`](#_.without)
|
||||
* [`_.wrap`](#_.wrap)
|
||||
@@ -92,19 +94,13 @@
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
## `_.prototype`
|
||||
* [`_#chain`](#_:chain)
|
||||
* [`_#value`](#_:value)
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
## `_.templateSettings`
|
||||
* [`_.templateSettings`](#_.templateSettings)
|
||||
* [`_.templateSettings.escape`](#_.templateSettings.escape)
|
||||
* [`_.templateSettings.evaluate`](#_.templateSettings.evaluate)
|
||||
* [`_.templateSettings.interpolate`](#_.templateSettings.interpolate)
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
@@ -121,15 +117,15 @@
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L80" title="View in source">`_(value)`</a>
|
||||
The Lodash function.
|
||||
### <a id="_" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L165" title="View in source">`_(value)`</a>
|
||||
The `lodash` function.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `value` *(Mixed)*: The value to wrap in a chainable `lodash` object.
|
||||
1. `value` *(Mixed)*: The value to wrap in a `Lodash` instance.
|
||||
|
||||
#### Returns
|
||||
*(Object)*: Returns a `lodash` instance.
|
||||
*(Object)*: Returns a `Lodash` instance.
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
@@ -137,13 +133,13 @@ The Lodash function.
|
||||
<!-- div -->
|
||||
|
||||
## `_`
|
||||
### <a id="_" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L80" title="View in source">`_(value)`</a>
|
||||
The Lodash function.
|
||||
### <a id="_" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L165" title="View in source">`_(value)`</a>
|
||||
The `lodash` function.
|
||||
[▲][1]
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.VERSION" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2514" title="View in source">`_.VERSION`</a>
|
||||
### <a id="_.VERSION" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2566" title="View in source">`_.VERSION`</a>
|
||||
*(String)*: The semantic version number.
|
||||
[▲][1]
|
||||
|
||||
@@ -152,7 +148,7 @@ The Lodash function.
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.after" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1189" title="View in source">`_.after(times, func)`</a>
|
||||
### <a id="_.after" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1326" title="View in source">`_.after(times, func)`</a>
|
||||
Creates a new function that is restricted to executing only after it is called a given number of `times`.
|
||||
[▲][1]
|
||||
|
||||
@@ -177,7 +173,7 @@ _.forEach(notes, function(note) {
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.bind" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1219" title="View in source">`_.bind(func [, arg1, arg2, ...])`</a>
|
||||
### <a id="_.bind" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1356" title="View in source">`_.bind(func [, arg1, arg2, ...])`</a>
|
||||
Creates a new function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends additional arguments to those passed to the bound function.
|
||||
[▲][1]
|
||||
|
||||
@@ -201,7 +197,7 @@ func();
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.bindAll" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1253" title="View in source">`_.bindAll(object [, methodName1, methodName2, ...])`</a>
|
||||
### <a id="_.bindAll" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1390" title="View in source">`_.bindAll(object [, methodName1, methodName2, ...])`</a>
|
||||
Binds methods on the `object` to the object, overwriting the non-bound method. If no method names are provided, all the function properties of the `object` will be bound.
|
||||
[▲][1]
|
||||
|
||||
@@ -230,7 +226,25 @@ jQuery('#lodash_button').on('click', buttonView.onClick);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.chain" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2458" title="View in source">`_.chain(value)`</a>
|
||||
### <a id="_.chain" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2535" title="View in source">`_.chain()`</a>
|
||||
Extracts the value from a wrapped chainable object.
|
||||
[▲][1]
|
||||
|
||||
#### Returns
|
||||
*(Mixed)*: Returns the wrapped object.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
_([1, 2, 3]).value();
|
||||
// => [1, 2, 3]
|
||||
~~~
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.chain" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2519" title="View in source">`_.chain(value)`</a>
|
||||
Wraps the value in a `lodash` chainable object.
|
||||
[▲][1]
|
||||
|
||||
@@ -261,7 +275,7 @@ var youngest = _.chain(stooges)
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.clone" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1524" title="View in source">`_.clone(value)`</a>
|
||||
### <a id="_.clone" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1661" title="View in source">`_.clone(value)`</a>
|
||||
Create a shallow clone of the `value`. Any nested objects or arrays will be assigned by reference and not cloned.
|
||||
[▲][1]
|
||||
|
||||
@@ -282,7 +296,7 @@ _.clone({ 'name': 'moe' });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.compact" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L786" title="View in source">`_.compact(array)`</a>
|
||||
### <a id="_.compact" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L923" title="View in source">`_.compact(array)`</a>
|
||||
Produces a new array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
|
||||
[▲][1]
|
||||
|
||||
@@ -303,7 +317,7 @@ _.compact([0, 1, false, 2, '', 3]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.compose" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1285" title="View in source">`_.compose([func1, func2, ...])`</a>
|
||||
### <a id="_.compose" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1422" title="View in source">`_.compose([func1, func2, ...])`</a>
|
||||
Creates a new function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing thefunctions `f()`, `g()`, and `h()` produces `f(g(h()))`.
|
||||
[▲][1]
|
||||
|
||||
@@ -327,7 +341,7 @@ welcome('moe');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.contains" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L204" title="View in source">`_.contains(collection, target)`</a>
|
||||
### <a id="_.contains" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L338" title="View in source">`_.contains(collection, target)`</a>
|
||||
Checks if a given `target` value is present in a `collection` using strict equality for comparisons, i.e. `===`.
|
||||
[▲][1]
|
||||
|
||||
@@ -349,14 +363,14 @@ _.contains([1, 2, 3], 3);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.debounce" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1315" title="View in source">`_.debounce(func, wait, immediate)`</a>
|
||||
Creates a new function that will postpone its execution until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke the function on the leading, intead of the trailing, edge of the wait timeout.
|
||||
### <a id="_.debounce" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1454" title="View in source">`_.debounce(func, wait, immediate)`</a>
|
||||
Creates a new function that will postpone its execution until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke the function on the leading, instead of the trailing, edge of the `wait` timeout.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `func` *(Function)*: The function to debounce.
|
||||
2. `wait` *(Number)*: The number of milliseconds to postone.
|
||||
3. `immediate` *(Boolean)*: A flag to indicate execution is on the leading edge of the wait timeout.
|
||||
3. `immediate` *(Boolean)*: A flag to indicate execution is on the leading edge of the timeout.
|
||||
|
||||
#### Returns
|
||||
*(Function)*: Returns the new debounced function.
|
||||
@@ -372,7 +386,7 @@ jQuery(window).on('resize', lazyLayout);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.defaults" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1548" title="View in source">`_.defaults(object [, defaults1, defaults2, ..])`</a>
|
||||
### <a id="_.defaults" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1685" title="View in source">`_.defaults(object [, defaults1, defaults2, ..])`</a>
|
||||
Assigns missing properties in `object` with default values from the defaults objects. As soon as a property is set, additional defaults of the same property will be ignored.
|
||||
[▲][1]
|
||||
|
||||
@@ -395,7 +409,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'lots' });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.defer" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1371" title="View in source">`_.defer(func [, arg1, arg2, ...])`</a>
|
||||
### <a id="_.defer" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1510" title="View in source">`_.defer(func [, arg1, arg2, ...])`</a>
|
||||
Defers invoking the `func` function until the current call stack has cleared. Additional arguments are passed to `func` when it is invoked.
|
||||
[▲][1]
|
||||
|
||||
@@ -417,7 +431,7 @@ _.defer(function() { alert('deferred'); });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.delay" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1351" title="View in source">`_.delay(func, wait [, arg1, arg2, ...])`</a>
|
||||
### <a id="_.delay" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1490" title="View in source">`_.delay(func, wait [, arg1, arg2, ...])`</a>
|
||||
Invokes the `func` function after `wait` milliseconds. Additional arguments are passed `func` when it is invoked.
|
||||
[▲][1]
|
||||
|
||||
@@ -441,7 +455,7 @@ _.delay(log, 1000, 'logged later');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.difference" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L806" title="View in source">`_.difference(array [, array1, array2, ...])`</a>
|
||||
### <a id="_.difference" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L945" title="View in source">`_.difference(array [, array1, array2, ...])`</a>
|
||||
Produces a new array of `array` values not present in the other arrays using strict equality for comparisons, i.e. `===`.
|
||||
[▲][1]
|
||||
|
||||
@@ -463,7 +477,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.escape" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2180" title="View in source">`_.escape(string)`</a>
|
||||
### <a id="_.escape" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2236" title="View in source">`_.escape(string)`</a>
|
||||
Escapes a string for insertion into HTML, replacing `&`, `<`, `>`, `"`, `'`, and `/` characters.
|
||||
[▲][1]
|
||||
|
||||
@@ -484,7 +498,7 @@ _.escape('Curly, Larry & Moe');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.every" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L229" title="View in source">`_.every(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.every" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L362" title="View in source">`_.every(collection, callback [, thisArg])`</a>
|
||||
Checks if the `callback` returns truthy for **all** values of a `collection`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -507,16 +521,16 @@ _.every([true, 1, null, 'yes'], Boolean);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.extend" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1572" title="View in source">`_.extend(destination [, source1, source2, ..])`</a>
|
||||
### <a id="_.extend" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1704" title="View in source">`_.extend(object [, source1, source2, ..])`</a>
|
||||
Copies enumerable properties from the source objects to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `destination` *(Object)*: The destination object.
|
||||
1. `object` *(Object)*: The destination object.
|
||||
2. `[source1, source2, ..]` *(Object)*: The source objects.
|
||||
|
||||
#### Returns
|
||||
*(Object)*: Returns the `destination` object.
|
||||
*(Object)*: Returns the destination object.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
@@ -529,7 +543,7 @@ _.extend({ 'name': 'moe' }, { 'age': 40 });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.filter" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L255" title="View in source">`_.filter(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.filter" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L383" title="View in source">`_.filter(collection, callback [, thisArg])`</a>
|
||||
Examines each value in a `collection`, returning an array of all values the `callback` returns truthy for. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -552,7 +566,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; })
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.find" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L280" title="View in source">`_.find(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.find" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L405" title="View in source">`_.find(collection, callback [, thisArg])`</a>
|
||||
Examines each value in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable value, and does not iterate over the entire `collection`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -562,7 +576,7 @@ Examines each value in a `collection`, returning the first one the `callback` re
|
||||
3. `[thisArg]` *(Mixed)*: The `this` binding for the callback.
|
||||
|
||||
#### Returns
|
||||
*(Mixed)*: Returns the value that passed the callback check.
|
||||
*(Mixed)*: Returns the value that passed the callback check, else `undefined`.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
@@ -575,14 +589,14 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.first" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L830" title="View in source">`_.first(array [, n, guard])`</a>
|
||||
### <a id="_.first" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L966" title="View in source">`_.first(array [, n, guard])`</a>
|
||||
Gets the first value of the `array`. Pass `n` to return the first `n` values of the `array`.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to query.
|
||||
2. `[n]` *(Number)*: The number of elements to return.
|
||||
3. `[guard]` *(Object)*: Allows this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
|
||||
#### Returns
|
||||
*(Mixed)*: Returns the first value or an array of the first `n` values of the `array`.
|
||||
@@ -598,7 +612,7 @@ _.first([5, 4, 3, 2, 1]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.flatten" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L852" title="View in source">`_.flatten(array, shallow)`</a>
|
||||
### <a id="_.flatten" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L988" title="View in source">`_.flatten(array, shallow)`</a>
|
||||
Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level.
|
||||
[▲][1]
|
||||
|
||||
@@ -623,7 +637,7 @@ _.flatten([1, [2], [3, [[4]]]], true);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.forEach" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L307" title="View in source">`_.forEach(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.forEach" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L431" title="View in source">`_.forEach(collection, callback [, thisArg])`</a>
|
||||
Iterates over a `collection`, executing the `callback` for each value in the `collection`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -649,8 +663,8 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3}, function(num) { alert(num); });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.functions" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1596" title="View in source">`_.functions(object)`</a>
|
||||
Produces a sorted array of the `object`'s enumerable own property names that have function values.
|
||||
### <a id="_.functions" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1721" title="View in source">`_.functions(object)`</a>
|
||||
Produces a sorted array of the properties, own and inherited, of `object` that have function values.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
@@ -670,7 +684,7 @@ _.functions(_);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.groupBy" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L335" title="View in source">`_.groupBy(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.groupBy" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L455" title="View in source">`_.groupBy(collection, callback [, thisArg])`</a>
|
||||
Splits a `collection` into sets, grouped by the result of running each value through `callback`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. The `callback` argument may also be the name of a property to group by.
|
||||
[▲][1]
|
||||
|
||||
@@ -696,13 +710,13 @@ _.groupBy(['one', 'two', 'three'], 'length');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.has" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1620" title="View in source">`_.has(object, key)`</a>
|
||||
Checks if an object has the specified key as a direct property.
|
||||
### <a id="_.has" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1743" title="View in source">`_.has(object, property)`</a>
|
||||
Checks if the specified object `property` exists and is a direct property, instead of an inherited property.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `object` *(Object)*: The object to check.
|
||||
2. `key` *(String)*: The key to check for.
|
||||
2. `property` *(String)*: The property to check for.
|
||||
|
||||
#### Returns
|
||||
*(Boolean)*: Returns `true` if key is a direct property, else `false`.
|
||||
@@ -718,8 +732,8 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.identity" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2202" title="View in source">`_.identity(value)`</a>
|
||||
This function simply returns the first argument passed to it. Note: It is used throughout Lodash as a default callback.
|
||||
### <a id="_.identity" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2261" title="View in source">`_.identity(value)`</a>
|
||||
This function simply returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
@@ -740,7 +754,7 @@ moe === _.identity(moe);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.indexOf" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L883" title="View in source">`_.indexOf(array, value [, isSorted=false])`</a>
|
||||
### <a id="_.indexOf" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1019" title="View in source">`_.indexOf(array, value [, isSorted=false])`</a>
|
||||
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.
|
||||
[▲][1]
|
||||
|
||||
@@ -763,14 +777,14 @@ _.indexOf([1, 2, 3], 2);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.initial" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L917" title="View in source">`_.initial(array [, n, guard])`</a>
|
||||
### <a id="_.initial" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1053" title="View in source">`_.initial(array [, n, guard])`</a>
|
||||
Gets all but the last value of the `array`. Pass `n` to exclude the last `n` values from the result.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to query.
|
||||
2. `[n]` *(Number)*: The number of elements to return.
|
||||
3. `[guard]` *(Object)*: Allows this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
|
||||
#### Returns
|
||||
*(Array)*: Returns all but the last value or `n` values of the `array`.
|
||||
@@ -786,7 +800,7 @@ _.initial([5, 4, 3, 2, 1]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.intersection" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L936" title="View in source">`_.intersection([array1, array2, ...])`</a>
|
||||
### <a id="_.intersection" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1072" title="View in source">`_.intersection([array1, array2, ...])`</a>
|
||||
Computes the intersection of all the passed-in arrays.
|
||||
[▲][1]
|
||||
|
||||
@@ -807,7 +821,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.invoke" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L364" title="View in source">`_.invoke(collection, methodName [, arg1, arg2, ...])`</a>
|
||||
### <a id="_.invoke" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L484" title="View in source">`_.invoke(collection, methodName [, arg1, arg2, ...])`</a>
|
||||
Calls the method named by `methodName` for each value of the `collection`. Additional arguments will be passed to each invoked method.
|
||||
[▲][1]
|
||||
|
||||
@@ -830,7 +844,7 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isArguments" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1640" title="View in source">`_.isArguments(value)`</a>
|
||||
### <a id="_.isArguments" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1763" title="View in source">`_.isArguments(value)`</a>
|
||||
Checks if a `value` is an `arguments` object.
|
||||
[▲][1]
|
||||
|
||||
@@ -854,7 +868,7 @@ _.isArguments([1, 2, 3]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isArray" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1660" title="View in source">`_.isArray(value)`</a>
|
||||
### <a id="_.isArray" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L199" title="View in source">`_.isArray(value)`</a>
|
||||
Checks if a `value` is an array.
|
||||
[▲][1]
|
||||
|
||||
@@ -878,7 +892,7 @@ _.isArray([1, 2, 3]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isBoolean" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1677" title="View in source">`_.isBoolean(value)`</a>
|
||||
### <a id="_.isBoolean" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1786" title="View in source">`_.isBoolean(value)`</a>
|
||||
Checks if a `value` is a boolean *(`true` or `false`)* value.
|
||||
[▲][1]
|
||||
|
||||
@@ -899,7 +913,7 @@ _.isBoolean(null);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isDate" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1694" title="View in source">`_.isDate(value)`</a>
|
||||
### <a id="_.isDate" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1803" title="View in source">`_.isDate(value)`</a>
|
||||
Checks if a `value` is a date.
|
||||
[▲][1]
|
||||
|
||||
@@ -920,7 +934,7 @@ _.isDate(new Date);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isElement" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1711" title="View in source">`_.isElement(value)`</a>
|
||||
### <a id="_.isElement" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1820" title="View in source">`_.isElement(value)`</a>
|
||||
Checks if a `value` is a DOM element.
|
||||
[▲][1]
|
||||
|
||||
@@ -941,7 +955,7 @@ _.isElement(document.body);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isEmpty" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1732" title="View in source">`_.isEmpty(value)`</a>
|
||||
### <a id="_.isEmpty" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L220" title="View in source">`_.isEmpty(value)`</a>
|
||||
Checks if a `value` is empty. Arrays or strings with a length of `0` and objects with no enumerable own properties are considered "empty".
|
||||
[▲][1]
|
||||
|
||||
@@ -965,13 +979,14 @@ _.isEmpty({});
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isEqual" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1768" title="View in source">`_.isEqual(a, b)`</a>
|
||||
### <a id="_.isEqual" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1847" title="View in source">`_.isEqual(a, b [, stack])`</a>
|
||||
Performs a deep comparison between two values to determine if they are equivalent to each other.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `a` *(Mixed)*: The value to compare.
|
||||
2. `b` *(Mixed)*: The other value to compare.
|
||||
3. `[stack]` *(Array)*: Internally used to keep track of "seen" objects to avoid circular references.
|
||||
|
||||
#### Returns
|
||||
*(Boolean)*: Returns `true` if the values are equvalent, else `false`.
|
||||
@@ -993,7 +1008,7 @@ _.isEqual(moe, clone);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isFinite" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1911" title="View in source">`_.isFinite(value)`</a>
|
||||
### <a id="_.isFinite" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1990" title="View in source">`_.isFinite(value)`</a>
|
||||
Checks if a `value` is a finite number.
|
||||
[▲][1]
|
||||
|
||||
@@ -1020,7 +1035,7 @@ _.isFinite(Infinity);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isFunction" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1928" title="View in source">`_.isFunction(value)`</a>
|
||||
### <a id="_.isFunction" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2007" title="View in source">`_.isFunction(value)`</a>
|
||||
Checks if a `value` is a function.
|
||||
[▲][1]
|
||||
|
||||
@@ -1041,7 +1056,7 @@ _.isFunction(''.concat);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isNaN" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1976" title="View in source">`_.isNaN(value)`</a>
|
||||
### <a id="_.isNaN" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2055" title="View in source">`_.isNaN(value)`</a>
|
||||
Checks if a `value` is `NaN`. Note: this is not the same as native `isNaN`, which will return true for `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
|
||||
[▲][1]
|
||||
|
||||
@@ -1071,7 +1086,7 @@ _.isNaN(undefined);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isNull" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1997" title="View in source">`_.isNull(value)`</a>
|
||||
### <a id="_.isNull" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2076" title="View in source">`_.isNull(value)`</a>
|
||||
Checks if a `value` is `null`.
|
||||
[▲][1]
|
||||
|
||||
@@ -1095,7 +1110,7 @@ _.isNull(undefined);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isNumber" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2014" title="View in source">`_.isNumber(value)`</a>
|
||||
### <a id="_.isNumber" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2093" title="View in source">`_.isNumber(value)`</a>
|
||||
Checks if a `value` is a number.
|
||||
[▲][1]
|
||||
|
||||
@@ -1116,7 +1131,7 @@ _.isNumber(8.4 * 5;
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isObject" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1948" title="View in source">`_.isObject(value)`</a>
|
||||
### <a id="_.isObject" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2027" title="View in source">`_.isObject(value)`</a>
|
||||
Checks if a `value` is an object.
|
||||
[▲][1]
|
||||
|
||||
@@ -1140,7 +1155,7 @@ _.isObject(1);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isRegExp" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2031" title="View in source">`_.isRegExp(value)`</a>
|
||||
### <a id="_.isRegExp" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2110" title="View in source">`_.isRegExp(value)`</a>
|
||||
Checks if a `value` is a regular expression.
|
||||
[▲][1]
|
||||
|
||||
@@ -1161,7 +1176,7 @@ _.isRegExp(/moe/);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isString" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2048" title="View in source">`_.isString(value)`</a>
|
||||
### <a id="_.isString" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2127" title="View in source">`_.isString(value)`</a>
|
||||
Checks if a `value` is a string.
|
||||
[▲][1]
|
||||
|
||||
@@ -1182,7 +1197,7 @@ _.isString('moe');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.isUndefined" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2065" title="View in source">`_.isUndefined(value)`</a>
|
||||
### <a id="_.isUndefined" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2144" title="View in source">`_.isUndefined(value)`</a>
|
||||
Checks if a `value` is `undefined`.
|
||||
[▲][1]
|
||||
|
||||
@@ -1203,7 +1218,7 @@ _.isUndefined(void 0);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.keys" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2082" title="View in source">`_.keys(object)`</a>
|
||||
### <a id="_.keys" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2161" title="View in source">`_.keys(object)`</a>
|
||||
Produces an array of the `object`'s enumerable own property names.
|
||||
[▲][1]
|
||||
|
||||
@@ -1224,14 +1239,14 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.last" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L962" title="View in source">`_.last(array [, n, guard])`</a>
|
||||
### <a id="_.last" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1098" title="View in source">`_.last(array [, n, guard])`</a>
|
||||
Gets the last value of the `array`. Pass `n` to return the lasy `n` values of the `array`.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to query.
|
||||
2. `[n]` *(Number)*: The number of elements to return.
|
||||
3. `[guard]` *(Object)*: Allows this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
|
||||
#### Returns
|
||||
*(Array)*: Returns all but the last value or `n` values of the `array`.
|
||||
@@ -1247,7 +1262,7 @@ _.last([5, 4, 3, 2, 1]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.lastIndexOf" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L982" title="View in source">`_.lastIndexOf(array, value)`</a>
|
||||
### <a id="_.lastIndexOf" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1118" title="View in source">`_.lastIndexOf(array, value)`</a>
|
||||
Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`.
|
||||
[▲][1]
|
||||
|
||||
@@ -1269,7 +1284,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.map" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L395" title="View in source">`_.map(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.map" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L515" title="View in source">`_.map(collection, callback [, thisArg])`</a>
|
||||
Produces a new array of values by mapping each value in the `collection` through a transformation `callback`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1295,7 +1310,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.max" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L431" title="View in source">`_.max(collection [, callback, thisArg])`</a>
|
||||
### <a id="_.max" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L542" title="View in source">`_.max(collection [, callback, thisArg])`</a>
|
||||
Retrieves the maximum value of a `collection`. If `callback` is passed, it will be executed for each value in the `collection` to generate the criterion by which the value is ranked. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1324,13 +1339,13 @@ _.max(stooges, function(stooge) { return stooge.age; });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.memoize" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1395" title="View in source">`_.memoize(func [, hasher=_.identity])`</a>
|
||||
Creates a new function that memoizes the result of `func`. If `hasher` is passed, it will be used to compute the hash key for storing the result, based on the arguments to the original function. The default `hasher` uses the first argument to the memoized function as the cache key.
|
||||
### <a id="_.memoize" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1533" title="View in source">`_.memoize(func [, resolver])`</a>
|
||||
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.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `func` *(Function)*: The function to memoize the output of.
|
||||
2. `[hasher=_.identity]` *(Function)*: A function used to resolve the cache keyW.
|
||||
1. `func` *(Function)*: The function to have its output memoized.
|
||||
2. `[resolver]` *(Function)*: A function used to resolve the cache key.
|
||||
|
||||
#### Returns
|
||||
*(Function)*: Returns the new memoizing function.
|
||||
@@ -1347,7 +1362,7 @@ var fibonacci = _.memoize(function(n) {
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.min" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L471" title="View in source">`_.min(collection [, callback, thisArg])`</a>
|
||||
### <a id="_.min" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L563" title="View in source">`_.min(collection [, callback, thisArg])`</a>
|
||||
Retrieves the minimum value of a `collection`. If `callback` is passed, it will be executed for each value in the `collection` to generate the criterion by which the value is ranked. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1370,7 +1385,7 @@ _.min([10, 5, 100, 2, 1000]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.mixin" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2228" title="View in source">`_.mixin(object)`</a>
|
||||
### <a id="_.mixin" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2287" title="View in source">`_.mixin(object)`</a>
|
||||
Adds functions properties of `object` to the `lodash` function and chainable wrapper.
|
||||
[▲][1]
|
||||
|
||||
@@ -1397,7 +1412,7 @@ _('larry').capitalize();
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.noConflict" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2258" title="View in source">`_.noConflict()`</a>
|
||||
### <a id="_.noConflict" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2317" title="View in source">`_.noConflict()`</a>
|
||||
Reverts the '_' variable to its previous value and returns a reference to the `lodash` function.
|
||||
[▲][1]
|
||||
|
||||
@@ -1414,7 +1429,7 @@ var lodash = _.noConflict();
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.once" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1422" title="View in source">`_.once(func)`</a>
|
||||
### <a id="_.once" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1559" title="View in source">`_.once(func)`</a>
|
||||
Creates a new function that is restricted to one execution. Repeat calls to the function will return the value of the first call.
|
||||
[▲][1]
|
||||
|
||||
@@ -1437,7 +1452,7 @@ initialize();
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.pick" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2110" title="View in source">`_.pick(object [, prop1, prop2, ..])`</a>
|
||||
### <a id="_.pick" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2178" title="View in source">`_.pick(object [, prop1, prop2, ..])`</a>
|
||||
Creates an object composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names.
|
||||
[▲][1]
|
||||
|
||||
@@ -1459,7 +1474,7 @@ _.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.pluck" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L512" title="View in source">`_.pluck(collection, property)`</a>
|
||||
### <a id="_.pluck" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L588" title="View in source">`_.pluck(collection, property)`</a>
|
||||
Retrieves the value of a specified property from all values in a `collection`.
|
||||
[▲][1]
|
||||
|
||||
@@ -1487,7 +1502,7 @@ _.pluck(stooges, 'name');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.range" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1024" title="View in source">`_.range([start=0], end [, step=1])`</a>
|
||||
### <a id="_.range" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1160" title="View in source">`_.range([start=0], end [, step=1])`</a>
|
||||
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.
|
||||
[▲][1]
|
||||
|
||||
@@ -1522,7 +1537,7 @@ _.range(0);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.reduce" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L538" title="View in source">`_.reduce(collection, callback [, accumulator, thisArg])`</a>
|
||||
### <a id="_.reduce" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L618" title="View in source">`_.reduce(collection, callback [, accumulator, thisArg])`</a>
|
||||
Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1546,7 +1561,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.reduceRight" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L565" title="View in source">`_.reduceRight(collection, callback [, accumulator, thisArg])`</a>
|
||||
### <a id="_.reduceRight" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L652" title="View in source">`_.reduceRight(collection, callback [, accumulator, thisArg])`</a>
|
||||
The right-associative version of `_.reduce`. The `callback` is bound to the `thisArg` value, if one is passed. The `callback` is invoked with `4` arguments; for arrays they are *(accumulator, value, index, array)* and for objects they are *(accumulator, value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1571,7 +1586,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.reject" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L590" title="View in source">`_.reject(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.reject" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L705" title="View in source">`_.reject(collection, callback [, thisArg])`</a>
|
||||
The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1594,14 +1609,14 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.rest" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1060" title="View in source">`_.rest(array [, n, guard])`</a>
|
||||
### <a id="_.rest" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1196" title="View in source">`_.rest(array [, n, guard])`</a>
|
||||
The opposite of `_.initial`, this method gets all but the first value of the `array`. Pass `n` to exclude the first `n` values from the result.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `array` *(Array)*: The array to query.
|
||||
2. `[n]` *(Number)*: The number of elements to return.
|
||||
3. `[guard]` *(Object)*: Allows this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
3. `[guard]` *(Object)*: Internally used to allow this method to work with others like `_.map` without using their callback `index` argument for `n`.
|
||||
|
||||
#### Returns
|
||||
*(Array)*: Returns all but the first value or `n` values of the `array`.
|
||||
@@ -1617,7 +1632,7 @@ _.rest([5, 4, 3, 2, 1]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.result" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2288" title="View in source">`_.result(object, property)`</a>
|
||||
### <a id="_.result" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2347" title="View in source">`_.result(object, property)`</a>
|
||||
Resolves the value of `property` on `object`. If the property is a function it will be invoked and its result returned, else the property value is returned.
|
||||
[▲][1]
|
||||
|
||||
@@ -1649,7 +1664,7 @@ _.result(object, 'stuff');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.shuffle" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L609" title="View in source">`_.shuffle(collection)`</a>
|
||||
### <a id="_.shuffle" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L723" title="View in source">`_.shuffle(collection)`</a>
|
||||
Produces a new array of shuffled `collection` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
|
||||
[▲][1]
|
||||
|
||||
@@ -1670,7 +1685,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.size" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L634" title="View in source">`_.size(collection)`</a>
|
||||
### <a id="_.size" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L748" title="View in source">`_.size(collection)`</a>
|
||||
Gets the number of values in the `collection`.
|
||||
[▲][1]
|
||||
|
||||
@@ -1691,7 +1706,7 @@ _.size({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.some" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L704" title="View in source">`_.some(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.some" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L821" title="View in source">`_.some(collection, callback [, thisArg])`</a>
|
||||
Checks if the `callback` returns truthy for **any** value of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1714,7 +1729,7 @@ _.some([null, 0, 'yes', false]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.sortBy" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L658" title="View in source">`_.sortBy(collection, callback [, thisArg])`</a>
|
||||
### <a id="_.sortBy" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L775" title="View in source">`_.sortBy(collection, callback [, thisArg])`</a>
|
||||
Produces a new sorted array, ranked in ascending order by the results of running each value of a `collection` through `callback`. The `callback` is invoked with `3` arguments; for arrays they are *(value, index, array)* and for objects they are *(value, key, object)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1737,7 +1752,7 @@ _.sortBy([1, 2, 3, 4, 5, 6], function(num) { return Math.sin(num); });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.sortedIndex" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L731" title="View in source">`_.sortedIndex(array, value [, callback])`</a>
|
||||
### <a id="_.sortedIndex" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L846" title="View in source">`_.sortedIndex(array, value [, callback])`</a>
|
||||
Uses a binary search to determine the index at which the `value` should be inserted into the `collection` in order to maintain the `collection`'s sorted order. If `callback` is passed, it will be executed for each value in the `collection` to compute their sort ranking. The `callback` is invoked with `1` arguments.
|
||||
[▲][1]
|
||||
|
||||
@@ -1760,7 +1775,7 @@ _.sortedIndex([10, 20, 30, 40, 50], 35);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.tap" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2141" title="View in source">`_.tap(value, interceptor)`</a>
|
||||
### <a id="_.tap" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2215" title="View in source">`_.tap(value, interceptor)`</a>
|
||||
Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The primary purpose of this method is to "tap into" a method chain, in order to performoperations on intermediate results within the chain.
|
||||
[▲][1]
|
||||
|
||||
@@ -1787,20 +1802,21 @@ _.chain([1,2,3,200])
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.template" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2388" title="View in source">`_.template(text, data, settings)`</a>
|
||||
JavaScript micro-templating, similar to John Resig's implementation. Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
|
||||
### <a id="_.template" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2450" title="View in source">`_.template(text, data, options)`</a>
|
||||
A JavaScript micro-templating method, similar to John Resig's implementation. Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `text` *(String)*: The
|
||||
2. `data` *(Obect)*: The
|
||||
3. `settings` *(Object)*:
|
||||
1. `text` *(String)*: The template text.
|
||||
2. `data` *(Obect)*: The data object used to populate the text.
|
||||
3. `options` *(Object)*: The options object.
|
||||
|
||||
#### Returns
|
||||
*(String)*: Returns....
|
||||
*(Function, String)*: Returns a compiled function when no `data` object is given, else it returns the interpolated text.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
// using compiled template
|
||||
var compiled = _.template('hello: <%= name %>');
|
||||
compiled({ 'name': 'moe' });
|
||||
// => 'hello: moe'
|
||||
@@ -1813,12 +1829,12 @@ var template = _.template('<b><%- value %></b>');
|
||||
template({ 'value': '<script>' });
|
||||
// => '<b><script></b>'
|
||||
|
||||
|
||||
// using `print`
|
||||
var compiled = _.template('<% print("Hello " + epithet); %>');
|
||||
compiled({ 'epithet': 'stooge' });
|
||||
// => 'Hello stooge.'
|
||||
|
||||
|
||||
// using custom template settings
|
||||
_.templateSettings = {
|
||||
'interpolate': /\{\{(.+?)\}\}/g
|
||||
};
|
||||
@@ -1828,10 +1844,11 @@ template({ 'name': 'Mustache' });
|
||||
// => 'Hello Mustache!'
|
||||
|
||||
|
||||
// using the `variable` option
|
||||
_.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' });
|
||||
// => 'no'
|
||||
|
||||
|
||||
// using the `source` property
|
||||
<script>
|
||||
JST.project = <%= _.template(jstText).source %>;
|
||||
</script>
|
||||
@@ -1842,7 +1859,7 @@ _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.throttle" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1451" title="View in source">`_.throttle(func, wait)`</a>
|
||||
### <a id="_.throttle" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1588" title="View in source">`_.throttle(func, wait)`</a>
|
||||
Creates a new function that, when invoked, will only call the original function at most once per every `wait` milliseconds.
|
||||
[▲][1]
|
||||
|
||||
@@ -1864,7 +1881,7 @@ jQuery(window).on('scroll', throttled);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.times" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2309" title="View in source">`_.times(n, callback [, thisArg])`</a>
|
||||
### <a id="_.times" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2368" title="View in source">`_.times(n, callback [, thisArg])`</a>
|
||||
Executes the `callback` function `n` times.
|
||||
[▲][1]
|
||||
|
||||
@@ -1883,7 +1900,7 @@ _.times(3, function() { genie.grantWish(); });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.toArray" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L757" title="View in source">`_.toArray(collection)`</a>
|
||||
### <a id="_.toArray" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L872" title="View in source">`_.toArray(collection)`</a>
|
||||
Converts the `collection`, into an array. Useful for converting the `arguments` object.
|
||||
[▲][1]
|
||||
|
||||
@@ -1904,7 +1921,7 @@ Converts the `collection`, into an array. Useful for converting the `arguments`
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.union" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1078" title="View in source">`_.union([array1, array2, ...])`</a>
|
||||
### <a id="_.union" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1214" title="View in source">`_.union([array1, array2, ...])`</a>
|
||||
Computes the union of the passed-in arrays.
|
||||
[▲][1]
|
||||
|
||||
@@ -1925,7 +1942,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.uniq" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1103" title="View in source">`_.uniq(array [, isSorted=false, callback])`</a>
|
||||
### <a id="_.uniq" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1239" title="View in source">`_.uniq(array [, isSorted=false, callback])`</a>
|
||||
Produces a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each value of `array` is passed through a transformation `callback` before uniqueness is computed. The `callback` is invoked with `3` arguments; *(value, index, array)*.
|
||||
[▲][1]
|
||||
|
||||
@@ -1948,7 +1965,7 @@ _.uniq([1, 2, 1, 3, 1, 4]);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.uniqueId" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2332" title="View in source">`_.uniqueId([prefix])`</a>
|
||||
### <a id="_.uniqueId" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2391" title="View in source">`_.uniqueId([prefix])`</a>
|
||||
Generates a unique id. If `prefix` is passed, the id will be appended to it.
|
||||
[▲][1]
|
||||
|
||||
@@ -1969,12 +1986,30 @@ _.uniqueId('contact_');
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.values" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2160" title="View in source">`_.values(object)`</a>
|
||||
Produces an array of the `object`'s enumerable own property values.
|
||||
### <a id="_.value" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2551" title="View in source">`_.value()`</a>
|
||||
Extracts the value from a wrapped chainable object.
|
||||
[▲][1]
|
||||
|
||||
#### Returns
|
||||
*(Mixed)*: Returns the wrapped object.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
_([1, 2, 3]).value();
|
||||
// => [1, 2, 3]
|
||||
~~~
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.values" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L899" title="View in source">`_.values(collection)`</a>
|
||||
Produces an array of enumerable own property values of the `collection`.
|
||||
[▲][1]
|
||||
|
||||
#### Arguments
|
||||
1. `object` *(Object)*: The object to inspect.
|
||||
1. `collection` *(Array|Object)*: The collection to inspect.
|
||||
|
||||
#### Returns
|
||||
*(Array)*: Returns a new array of property values.
|
||||
@@ -1990,7 +2025,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.without" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1137" title="View in source">`_.without(array [, value1, value2, ...])`</a>
|
||||
### <a id="_.without" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1273" title="View in source">`_.without(array [, value1, value2, ...])`</a>
|
||||
Produces a new array with all occurrences of the values removed using strict equality for comparisons, i.e. `===`.
|
||||
[▲][1]
|
||||
|
||||
@@ -2012,7 +2047,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.wrap" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1500" title="View in source">`_.wrap(func, wrapper [, arg1, arg2, ...])`</a>
|
||||
### <a id="_.wrap" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1637" title="View in source">`_.wrap(func, wrapper [, arg1, arg2, ...])`</a>
|
||||
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.
|
||||
[▲][1]
|
||||
|
||||
@@ -2039,7 +2074,7 @@ hello();
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.zip" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1157" title="View in source">`_.zip([array1, array2, ...])`</a>
|
||||
### <a id="_.zip" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L1294" title="View in source">`_.zip([array1, array2, ...])`</a>
|
||||
Merges together the values of each of the arrays with the value at the corresponding position. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion.
|
||||
[▲][1]
|
||||
|
||||
@@ -2061,60 +2096,41 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
## `_.prototype`
|
||||
### <a id="_" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L80" title="View in source">`_(value)`</a>
|
||||
The Lodash function.
|
||||
[▲][1]
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_:chain" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2474" title="View in source">`_#chain()`</a>
|
||||
Extracts the value from a wrapped chainable object.
|
||||
[▲][1]
|
||||
|
||||
#### Returns
|
||||
*(Mixed)*: Returns the wrapped object.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
_([1, 2, 3]).value();
|
||||
// => [1, 2, 3]
|
||||
~~~
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_:value" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2490" title="View in source">`_#value()`</a>
|
||||
Extracts the value from a wrapped chainable object.
|
||||
[▲][1]
|
||||
|
||||
#### Returns
|
||||
*(Mixed)*: Returns the wrapped object.
|
||||
|
||||
#### Example
|
||||
~~~ js
|
||||
_([1, 2, 3]).value();
|
||||
// => [1, 2, 3]
|
||||
~~~
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
## `_.templateSettings`
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.templateSettings" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2524" title="View in source">`_.templateSettings`</a>
|
||||
*(Object)*: By default, Lodash uses ERB-style template delimiters, change the following template settings to use alternative delimiters.
|
||||
### <a id="_.templateSettings" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2576" title="View in source">`_.templateSettings`</a>
|
||||
*(Object)*: By default, Lo-Dash uses ERB-style template delimiters, change the following template settings to use alternative delimiters.
|
||||
[▲][1]
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.templateSettings.escape" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2585" title="View in source">`_.templateSettings.escape`</a>
|
||||
*(RegExp)*: Used to detect `data` property values to be HTML-escaped.
|
||||
[▲][1]
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.templateSettings.evaluate" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2594" title="View in source">`_.templateSettings.evaluate`</a>
|
||||
*(RegExp)*: Used to detect code to be evaluated.
|
||||
[▲][1]
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
|
||||
<!-- div -->
|
||||
|
||||
### <a id="_.templateSettings.interpolate" href="https://github.com/bestiejs/lodash/blob/master/lodash.js#L2603" title="View in source">`_.templateSettings.interpolate`</a>
|
||||
*(RegExp)*: Used to detect `data` property values to inject.
|
||||
[▲][1]
|
||||
|
||||
<!-- /div -->
|
||||
|
||||
330
lodash.js
330
lodash.js
@@ -8,67 +8,48 @@
|
||||
;(function(window, undefined) {
|
||||
'use strict';
|
||||
|
||||
/** Used to assign each benchmark an incrimented id */
|
||||
var idCounter = 0;
|
||||
/** Used to escape and unescape characters in templates */
|
||||
var escapes = {
|
||||
'\\': '\\',
|
||||
"'": "'",
|
||||
'r': '\r',
|
||||
'n': '\n',
|
||||
't': '\t',
|
||||
'u2028': '\u2028',
|
||||
'u2029': '\u2029'
|
||||
};
|
||||
|
||||
/** Detect free variable `exports` */
|
||||
var freeExports = typeof exports == 'object' && exports &&
|
||||
(typeof global == 'object' && global && global == global.global && (window = global), exports);
|
||||
|
||||
/** Used to restore the original `_` reference in `noConflict` */
|
||||
var oldDash = window._;
|
||||
|
||||
var reEscaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
|
||||
|
||||
// When customizing `templateSettings`, if you don't want to define an
|
||||
// interpolation, evaluation or escaping regex, we need one that is
|
||||
// guaranteed not to match.
|
||||
var reNoMatch = /.^/;
|
||||
|
||||
var reUnescaper = /\\(\\|'|r|n|t|u2028|u2029)/g;
|
||||
|
||||
var clearInteval = window.clearInterval;
|
||||
|
||||
var setTimeout = window.setTimeout;
|
||||
|
||||
// Certain characters need to be escaped so that they can be put into a
|
||||
// string literal.
|
||||
var escapes;
|
||||
// assign the result as keys and the keys as values
|
||||
(function() {
|
||||
escapes = {
|
||||
'\\': '\\',
|
||||
"'": "'",
|
||||
'r': '\r',
|
||||
'n': '\n',
|
||||
't': '\t',
|
||||
'u2028': '\u2028',
|
||||
'u2029': '\u2029'
|
||||
};
|
||||
|
||||
// assign the values as keys and the keys as values
|
||||
for (var prop in escapes) {
|
||||
escapes[escapes[prop]] = prop;
|
||||
}
|
||||
}());
|
||||
|
||||
// Save bytes in the minified (but not gzipped) version:
|
||||
var ArrayProto = Array.prototype,
|
||||
ObjProto = Object.prototype;
|
||||
/** Detect free variable `exports` */
|
||||
var freeExports = typeof exports == 'object' && exports &&
|
||||
(typeof global == 'object' && global && global == global.global && (window = global), exports);
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var concat = ArrayProto.concat,
|
||||
hasOwnProperty = ObjProto.hasOwnProperty,
|
||||
push = ArrayProto.push,
|
||||
slice = ArrayProto.slice,
|
||||
toString = ObjProto.toString,
|
||||
unshift = ArrayProto.unshift;
|
||||
/** Used to generate unique IDs */
|
||||
var idCounter = 0;
|
||||
|
||||
// All **ECMAScript 5** native function implementations that we hope to use
|
||||
// are declared here.
|
||||
var nativeIsArray = Array.isArray,
|
||||
nativeIsFinite = window.isFinite,
|
||||
nativeKeys = Object.keys;
|
||||
/** Used to restore the original `_` reference in `noConflict` */
|
||||
var oldDash = window._;
|
||||
|
||||
/** Used to replace unescape characters with their escaped counterpart */
|
||||
var reEscaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
|
||||
|
||||
/**
|
||||
* Used for `templateSettings` properties such as `escape`, `evaluate`,
|
||||
* or `interpolate` with explicitly assigned falsey values to ensure no match
|
||||
* is made.
|
||||
*/
|
||||
var reNoMatch = /.^/;
|
||||
|
||||
/** Used to replace escaped characters with their unescaped counterpart */
|
||||
var reUnescaper = /\\(\\|'|r|n|t|u2028|u2029)/g;
|
||||
|
||||
/** Object#toString result shortcuts */
|
||||
var arrayClass = '[object Array]',
|
||||
boolClass = '[object Boolean]',
|
||||
dateClass = '[object Date]',
|
||||
@@ -77,6 +58,28 @@
|
||||
regexpClass = '[object RegExp]',
|
||||
stringClass = '[object String]';
|
||||
|
||||
/** Native prototype shortcuts */
|
||||
var ArrayProto = Array.prototype,
|
||||
ObjProto = Object.prototype;
|
||||
|
||||
/** Native method shortcuts */
|
||||
var concat = ArrayProto.concat,
|
||||
hasOwnProperty = ObjProto.hasOwnProperty,
|
||||
push = ArrayProto.push,
|
||||
slice = ArrayProto.slice,
|
||||
toString = ObjProto.toString,
|
||||
unshift = ArrayProto.unshift;
|
||||
|
||||
/* Native method shortcuts for methods with the same name as a `lodash` method */
|
||||
var nativeIsArray = Array.isArray,
|
||||
nativeIsFinite = window.isFinite,
|
||||
nativeKeys = Object.keys;
|
||||
|
||||
/** Timer shortcuts */
|
||||
var clearInteval = window.clearInterval,
|
||||
setTimeout = window.setTimeout;
|
||||
|
||||
/** Compilation options for `_.difference` */
|
||||
var differenceFactoryOptions = {
|
||||
'args': 'array',
|
||||
'top': 'var values=concat.apply([],slice.call(arguments,1))',
|
||||
@@ -84,11 +87,13 @@
|
||||
'inLoop': 'indexOf(values,array[index])<0&&result.push(array[index])'
|
||||
};
|
||||
|
||||
/** Compilation options for `_.every` */
|
||||
var everyFactoryOptions = {
|
||||
'init': 'true',
|
||||
'inLoop': 'if(!callback(collection[index],index,collection))return !result'
|
||||
};
|
||||
|
||||
/** Compilation options for `_.extend` */
|
||||
var extendFactoryOptions = {
|
||||
'args': 'object',
|
||||
'init': 'object',
|
||||
@@ -99,11 +104,13 @@
|
||||
'afterLoop': '}'
|
||||
};
|
||||
|
||||
/** Compilation options for `_.filter` */
|
||||
var filterFactoryOptions = {
|
||||
'init': '[]',
|
||||
'inLoop': 'callback(collection[index],index,collection)&&result.push(collection[index])'
|
||||
};
|
||||
|
||||
/** Compilation options for `_.forEach` */
|
||||
var forEachFactoryOptions = {
|
||||
'args': 'collection,callback,thisArg',
|
||||
'top': 'if(!callback){\ncallback=identity\n}\nelse if(thisArg){\ncallback=bind(callback,thisArg)\n}',
|
||||
@@ -111,6 +118,7 @@
|
||||
'inLoop': 'callback(collection[index],index,collection)'
|
||||
};
|
||||
|
||||
/** Compilation options for `_.keys` */
|
||||
var keysFactoryOptions = {
|
||||
'args': 'object',
|
||||
'top': 'if(object!==Object(object))throw TypeError()',
|
||||
@@ -118,6 +126,7 @@
|
||||
'inLoop': 'result.push(index)'
|
||||
};
|
||||
|
||||
/** Compilation options for `_.map` */
|
||||
var mapFactoryOptions = {
|
||||
'init': '',
|
||||
'exits': '[]',
|
||||
@@ -131,6 +140,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
/** Compilation options for `_.max` */
|
||||
var maxFactoryOptions = {
|
||||
'top':
|
||||
'var current,result=-Infinity,computed=result;\n' +
|
||||
@@ -140,33 +150,32 @@
|
||||
'}else if(thisArg)callback=bind(callback,thisArg)',
|
||||
'inLoop':
|
||||
'current=callback?callback(collection[index],index,collection):collection[index];\n' +
|
||||
'if(current>=computed){computed=current;result=collection[index]}'
|
||||
'if(current>=computed)computed=current,result=collection[index]'
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The Lodash function.
|
||||
* The `lodash` function.
|
||||
*
|
||||
* @name _
|
||||
* @param {Mixed} value The value to wrap in a chainable `lodash` object.
|
||||
* @returns {Object} Returns a `lodash` instance.
|
||||
* @param {Mixed} value The value to wrap in a `Lodash` instance.
|
||||
* @returns {Object} Returns a `Lodash` instance.
|
||||
*/
|
||||
function lodash(value) {
|
||||
// allow invoking `lodash` without the `new` operator
|
||||
return new Wrapper(value);
|
||||
return new Lodash(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a wrapped collection that can be used OO-style. This wrapper holds
|
||||
* altered versions of all the Lo-Dash functions. Wrapped objects may be chained.
|
||||
* Creates a `Lodash` instance that wraps a value to allow chaining.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Mixed} value The value to wrap in a chainable `lodash` object.
|
||||
* @param {Mixed} value The value to wrap.
|
||||
*/
|
||||
function Wrapper(collection) {
|
||||
this._wrapped = collection;
|
||||
function Lodash(value) {
|
||||
this._wrapped = value;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -223,7 +232,7 @@
|
||||
* Compiles iteration functions.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} [options1, options2, ..] The options objects.
|
||||
* @param {Object} [options1, options2, ..] The compile options objects.
|
||||
* @returns {Function} Returns the compiled function.
|
||||
*/
|
||||
function iterationFactory() {
|
||||
@@ -293,13 +302,20 @@
|
||||
indexOf, Infinity, isArray, isEmpty, Math, slice, stringClass, toString);
|
||||
}
|
||||
|
||||
// Within an interpolation, evaluation, or escaping, remove HTML escaping
|
||||
// that had been previously added.
|
||||
function unescape(code) {
|
||||
return code.replace(reUnescaper, function(match, escape) {
|
||||
return escapes[escape];
|
||||
/**
|
||||
* Unescapes characters, previously escaped for inclusion in compiled string
|
||||
* literals, so they may compiled into function bodies.
|
||||
* (Used for template interpolation, evaluation, or escaping)
|
||||
*
|
||||
* @private
|
||||
* @param {String} string The string to unescape.
|
||||
* @returns {String} Returns the unescaped string.
|
||||
*/
|
||||
function unescape(string) {
|
||||
return string.replace(reUnescaper, function(match, escaped) {
|
||||
return escapes[escaped];
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -1747,6 +1763,7 @@
|
||||
var isArguments = function isArguments(value) {
|
||||
return toString.call(value) == '[object Arguments]';
|
||||
};
|
||||
// fallback for browser like IE<9 which detect `arguments` as `[object Object]`
|
||||
if (!isArguments(arguments)) {
|
||||
isArguments = function isArguments(value) {
|
||||
return !!(value && hasOwnProperty.call(value, 'callee'));
|
||||
@@ -2218,14 +2235,17 @@
|
||||
*/
|
||||
function escape(string) {
|
||||
return (string + '')
|
||||
.replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"')
|
||||
.replace(/'/g, ''').replace(/\//g,'/');
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/\//g,'/');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function simply returns the first argument passed to it.
|
||||
* Note: It is used throughout Lodash as a default callback.
|
||||
* Note: It is used throughout Lo-Dash as a default callback.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -2277,7 +2297,7 @@
|
||||
unshift.call(args, this._wrapped);
|
||||
|
||||
var result = func.apply(lodash, args);
|
||||
return this._chain ? lodash(result).chain() : result;
|
||||
return this._chain ? new Lodash(result).chain() : result;
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -2376,19 +2396,21 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* JavaScript micro-templating, similar to John Resig's implementation.
|
||||
* Lo-Dash templating handles arbitrary delimiters, preserves whitespace,
|
||||
* and correctly escapes quotes within interpolated code.
|
||||
* A JavaScript micro-templating method, similar to John Resig's implementation.
|
||||
* Lo-Dash templating handles arbitrary delimiters, preserves whitespace, and
|
||||
* correctly escapes quotes within interpolated code.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utilities
|
||||
* @param {String} text The
|
||||
* @param {Obect} data The
|
||||
* @param {Object} settings
|
||||
* @returns {String} Returns....
|
||||
* @param {String} text The template text.
|
||||
* @param {Obect} data The data object used to populate the text.
|
||||
* @param {Object} options The options object.
|
||||
* @returns {Function|String} Returns a compiled function when no `data` object
|
||||
* is given, else it returns the interpolated text.
|
||||
* @example
|
||||
*
|
||||
* // using compiled template
|
||||
* var compiled = _.template('hello: <%= name %>');
|
||||
* compiled({ 'name': 'moe' });
|
||||
* // => 'hello: moe'
|
||||
@@ -2401,12 +2423,12 @@
|
||||
* template({ 'value': '<script>' });
|
||||
* // => '<b><script></b>'
|
||||
*
|
||||
*
|
||||
* // using `print`
|
||||
* var compiled = _.template('<% print("Hello " + epithet); %>');
|
||||
* compiled({ 'epithet': 'stooge' });
|
||||
* // => 'Hello stooge.'
|
||||
*
|
||||
*
|
||||
* // using custom template settings
|
||||
* _.templateSettings = {
|
||||
* 'interpolate': /\{\{(.+?)\}\}/g
|
||||
* };
|
||||
@@ -2416,44 +2438,45 @@
|
||||
* // => 'Hello Mustache!'
|
||||
*
|
||||
*
|
||||
* // using the `variable` option
|
||||
* _.template('<%= data.hasWith %>', { 'hasWith': 'no' }, { 'variable': 'data' });
|
||||
* // => 'no'
|
||||
*
|
||||
*
|
||||
* // using the `source` property
|
||||
* <script>
|
||||
* JST.project = <%= _.template(jstText).source %>;
|
||||
* </script>
|
||||
*/
|
||||
function template(text, data, settings) {
|
||||
settings = defaults(settings || {}, lodash.templateSettings);
|
||||
function template(text, data, options) {
|
||||
options = defaults(options || {}, lodash.templateSettings);
|
||||
|
||||
// Compile the template source, taking care to escape characters that
|
||||
// cannot be included in a string literal and then unescape them in code
|
||||
// cannot be included in string literals and then unescape them in code
|
||||
// blocks.
|
||||
var source = "__p+='" + text
|
||||
.replace(reEscaper, function(match) {
|
||||
return '\\' + escapes[match];
|
||||
})
|
||||
.replace(settings.escape || reNoMatch, function(match, code) {
|
||||
.replace(options.escape || reNoMatch, function(match, code) {
|
||||
return "'+\n_.escape(" + unescape(code) + ")+\n'";
|
||||
})
|
||||
.replace(settings.interpolate || reNoMatch, function(match, code) {
|
||||
.replace(options.interpolate || reNoMatch, function(match, code) {
|
||||
return "'+\n(" + unescape(code) + ")+\n'";
|
||||
})
|
||||
.replace(settings.evaluate || reNoMatch, function(match, code) {
|
||||
return "';\n" + unescape(code) + "\n;__p+='";
|
||||
.replace(options.evaluate || reNoMatch, function(match, code) {
|
||||
return "';\n" + unescape(code) + ";\n__p+='";
|
||||
}) + "';\n";
|
||||
|
||||
// If a variable is not specified, place data values in local scope.
|
||||
if (!settings.variable) {
|
||||
// if a variable is not specified, place data values in local scope
|
||||
if (!options.variable) {
|
||||
source = 'with(object||{}){\n' + source + '\n}\n';
|
||||
}
|
||||
|
||||
source = "var __p='';" +
|
||||
"function print(){__p+=Array.prototype.join.call(arguments,'')}\n" +
|
||||
source + "return __p\n";
|
||||
source = 'var __p="";' +
|
||||
'function print(){__p+=Array.prototype.join.call(arguments,"")}\n' +
|
||||
source + 'return __p';
|
||||
|
||||
var render = Function(settings.variable || 'object', '_', source);
|
||||
var render = Function(options.variable || 'object', '_', source);
|
||||
if (data) {
|
||||
return render(data, lodash);
|
||||
}
|
||||
@@ -2461,10 +2484,9 @@
|
||||
var template = function(data) {
|
||||
return render.call(this, data, lodash);
|
||||
};
|
||||
// Provide the compiled function source as a convenience for build time
|
||||
// precompilation.
|
||||
template.source = 'function(' + (settings.variable || 'object') + '){\n' +
|
||||
source + '}';
|
||||
|
||||
// provide the compiled function source as a convenience for build time precompilation
|
||||
template.source = 'function(' + (options.variable || 'object') + '){\n' + source + '\n}';
|
||||
|
||||
return template;
|
||||
}
|
||||
@@ -2495,7 +2517,7 @@
|
||||
* // => 'moe is 40'
|
||||
*/
|
||||
function chain(value) {
|
||||
return lodash(value).chain();
|
||||
return new Lodash(value).chain();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2532,31 +2554,56 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The semantic version number.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type String
|
||||
*/
|
||||
lodash.VERSION = '0.1.0';
|
||||
|
||||
/**
|
||||
* By default, Lodash uses ERB-style template delimiters, change the following
|
||||
* template settings to use alternative delimiters.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Object
|
||||
*/
|
||||
lodash.templateSettings = {
|
||||
'escape': /<%-([\s\S]+?)%>/g,
|
||||
'evaluate': /<%([\s\S]+?)%>/g,
|
||||
'interpolate': /<%=([\s\S]+?)%>/g
|
||||
};
|
||||
|
||||
// assign static properties
|
||||
extend(lodash, {
|
||||
|
||||
/**
|
||||
* The semantic version number.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type String
|
||||
*/
|
||||
'VERSION': '0.1.0',
|
||||
|
||||
/**
|
||||
* By default, Lo-Dash uses ERB-style template delimiters, change the
|
||||
* following template settings to use alternative delimiters.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Object
|
||||
*/
|
||||
'templateSettings': {
|
||||
|
||||
/**
|
||||
* Used to detect `data` property values to be HTML-escaped.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _.templateSettings
|
||||
* @type RegExp
|
||||
*/
|
||||
'escape': /<%-([\s\S]+?)%>/g,
|
||||
|
||||
/**
|
||||
* Used to detect code to be evaluated.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _.templateSettings
|
||||
* @type RegExp
|
||||
*/
|
||||
'evaluate': /<%([\s\S]+?)%>/g,
|
||||
|
||||
/**
|
||||
* Used to detect `data` property values to inject.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _.templateSettings
|
||||
* @type RegExp
|
||||
*/
|
||||
'interpolate': /<%=([\s\S]+?)%>/g
|
||||
},
|
||||
|
||||
// assign static methods
|
||||
'after': after,
|
||||
'bind': bind,
|
||||
'bindAll': bindAll,
|
||||
@@ -2636,11 +2683,9 @@
|
||||
'values': values,
|
||||
'without': without,
|
||||
'wrap': wrap,
|
||||
'zip': zip
|
||||
});
|
||||
'zip': zip,
|
||||
|
||||
// assign aliases
|
||||
extend(lodash, {
|
||||
// assign aliases
|
||||
'all': every,
|
||||
'any': some,
|
||||
'collect': map,
|
||||
@@ -2661,42 +2706,43 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// Hookup private Wrapper's prototype
|
||||
Wrapper.prototype = lodash.prototype;
|
||||
// assign private `Lodash` constructor's prototype
|
||||
Lodash.prototype = lodash.prototype;
|
||||
|
||||
// Add all of the Lo-Dash functions to the wrapper collection.
|
||||
// add all of the static functions to `Lodash.prototype`
|
||||
mixin(lodash);
|
||||
|
||||
// Add all mutator Array functions to the wrapper.
|
||||
// add all mutator Array functions to the wrapper.
|
||||
forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
|
||||
var func = ArrayProto[methodName];
|
||||
|
||||
lodash.prototype[methodName] = function() {
|
||||
var wrapped = this._wrapped;
|
||||
func.apply(wrapped, arguments);
|
||||
var value = this._wrapped;
|
||||
func.apply(value, arguments);
|
||||
|
||||
// IE compatibility mode and IE < 9 have buggy Array `shift()` and `splice()`
|
||||
// functions that fail to remove the last element, `object[0]`, of
|
||||
// array-like-objects even though the `length` property is set to `0`.
|
||||
// The `shift()` method is buggy in IE 8 compatibility mode, while `splice()`
|
||||
// is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9.
|
||||
if (wrapped.length === 0) {
|
||||
delete wrapped[0];
|
||||
if (value.length === 0) {
|
||||
delete value[0];
|
||||
}
|
||||
return this._chain ? lodash(wrapped).chain() : wrapped;
|
||||
return this._chain ? new Lodash(value).chain() : value;
|
||||
};
|
||||
});
|
||||
|
||||
// Add all accessor Array functions to the wrapper.
|
||||
// add all accessor Array functions to the wrapper.
|
||||
forEach(['concat', 'join', 'slice'], function(methodName) {
|
||||
var func = ArrayProto[methodName];
|
||||
lodash.prototype[methodName] = function() {
|
||||
Lodash.prototype[methodName] = function() {
|
||||
var result = func.apply(this._wrapped, arguments);
|
||||
return this._chain ? lodash(result).chain() : result;
|
||||
return this._chain ? new Lodash(result).chain() : result;
|
||||
};
|
||||
});
|
||||
|
||||
extend(lodash.prototype, {
|
||||
// add `chain` and `value` after calling to `mixin()` to avoid getting wrapped
|
||||
extend(Lodash.prototype, {
|
||||
'chain': chainWrapper,
|
||||
'value': value
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user