mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Rebuild docs and dist.
Former-commit-id: ae113f2c04eef7a34b1b49bca3e6dcb7402f723c
This commit is contained in:
114
dist/lodash.underscore.js
vendored
114
dist/lodash.underscore.js
vendored
@@ -233,7 +233,6 @@
|
||||
*
|
||||
* @name _
|
||||
* @constructor
|
||||
* @alias chain
|
||||
* @category Chaining
|
||||
* @param {Mixed} value The value to wrap in a `lodash` instance.
|
||||
* @returns {Object} Returns a `lodash` instance.
|
||||
@@ -269,9 +268,11 @@
|
||||
*
|
||||
* @private
|
||||
* @param {Mixed} value The value to wrap in a `lodash` instance.
|
||||
* @param {Boolean} chainAll A flag to enable chaining for all methods
|
||||
* @returns {Object} Returns a `lodash` instance.
|
||||
*/
|
||||
function lodashWrapper(value) {
|
||||
function lodashWrapper(value, chainAll) {
|
||||
this.__chain__ = !!chainAll;
|
||||
this.__wrapped__ = value;
|
||||
}
|
||||
// ensure `new lodashWrapper` is an instance of `lodash`
|
||||
@@ -705,6 +706,7 @@
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
|
||||
@@ -936,13 +938,13 @@
|
||||
* }
|
||||
*
|
||||
* Dog.prototype.bark = function() {
|
||||
* alert('Woof, woof!');
|
||||
* console.log('Woof, woof!');
|
||||
* };
|
||||
*
|
||||
* _.forIn(new Dog('Dagny'), function(value, key) {
|
||||
* alert(key);
|
||||
* console.log(key);
|
||||
* });
|
||||
* // => alerts 'name' and 'bark' (order is not guaranteed)
|
||||
* // => logs 'bark' and 'name' (order is not guaranteed)
|
||||
*/
|
||||
var forIn = function(collection, callback) {
|
||||
var index, iterable = collection, result = iterable;
|
||||
@@ -971,9 +973,9 @@
|
||||
* @example
|
||||
*
|
||||
* _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
|
||||
* alert(key);
|
||||
* console.log(key);
|
||||
* });
|
||||
* // => alerts '0', '1', and 'length' (order is not guaranteed)
|
||||
* // => logs '0', '1', and 'length' (order is not guaranteed)
|
||||
*/
|
||||
var forOwn = function(collection, callback) {
|
||||
var index, iterable = collection, result = iterable;
|
||||
@@ -1840,11 +1842,11 @@
|
||||
* @returns {Array|Object|String} Returns `collection`.
|
||||
* @example
|
||||
*
|
||||
* _([1, 2, 3]).forEach(alert).join(',');
|
||||
* // => alerts each number and returns '1,2,3'
|
||||
* _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(',');
|
||||
* // => logs each number and returns '1,2,3'
|
||||
*
|
||||
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
|
||||
* // => alerts each number value (order is not guaranteed)
|
||||
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
|
||||
* // => logs each number value and returns the object (order is not guaranteed)
|
||||
*/
|
||||
function forEach(collection, callback, thisArg) {
|
||||
var index = -1,
|
||||
@@ -1862,6 +1864,41 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is like `_.forEach`, except that it iterates over elements
|
||||
* of a `collection` from right to left.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias each
|
||||
* @category Collections
|
||||
* @param {Array|Object|String} collection The collection to iterate over.
|
||||
* @param {Function} [callback=identity] The function called per iteration.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array|Object|String} Returns `collection`.
|
||||
* @example
|
||||
*
|
||||
* _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(',');
|
||||
* // => logs each number from right to left and returns '3,2,1'
|
||||
*/
|
||||
function forEachRight(collection, callback, thisArg) {
|
||||
var iterable = collection,
|
||||
length = collection ? collection.length : 0;
|
||||
|
||||
if (typeof length != 'number') {
|
||||
var props = keys(collection);
|
||||
length = props.length;
|
||||
} else if (support.unindexedChars && isString(collection)) {
|
||||
iterable = collection.split('');
|
||||
}
|
||||
callback = createCallback(callback, thisArg, 3);
|
||||
forEach(collection, function(value, index, collection) {
|
||||
index = props ? props[--length] : --length;
|
||||
callback(iterable[index], index, collection);
|
||||
});
|
||||
return collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object composed of keys generated from the results of running
|
||||
* each element of the `collection` through the `callback`. The corresponding
|
||||
@@ -2217,7 +2254,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is similar to `_.reduce`, except that it iterates over elements
|
||||
* This method is like `_.reduce`, except that it iterates over elements
|
||||
* of a `collection` from right to left.
|
||||
*
|
||||
* @static
|
||||
@@ -2236,20 +2273,12 @@
|
||||
* // => [4, 5, 2, 3, 0, 1]
|
||||
*/
|
||||
function reduceRight(collection, callback, accumulator, thisArg) {
|
||||
var iterable = collection,
|
||||
length = collection ? collection.length : 0,
|
||||
noaccum = arguments.length < 3;
|
||||
|
||||
if (typeof length != 'number') {
|
||||
var props = keys(collection);
|
||||
length = props.length;
|
||||
}
|
||||
var noaccum = arguments.length < 3;
|
||||
callback = createCallback(callback, thisArg, 4);
|
||||
forEach(collection, function(value, index, collection) {
|
||||
index = props ? props[--length] : --length;
|
||||
forEachRight(collection, function(value, index, collection) {
|
||||
accumulator = noaccum
|
||||
? (noaccum = false, iterable[index])
|
||||
: callback(accumulator, iterable[index], index, collection);
|
||||
? (noaccum = false, value)
|
||||
: callback(accumulator, value, index, collection);
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
@@ -3384,12 +3413,12 @@
|
||||
*
|
||||
* var view = {
|
||||
* 'label': 'docs',
|
||||
* 'onClick': function() { alert('clicked ' + this.label); }
|
||||
* 'onClick': function() { console.log('clicked ' + this.label); }
|
||||
* };
|
||||
*
|
||||
* _.bindAll(view);
|
||||
* jQuery('#docs').on('click', view.onClick);
|
||||
* // => alerts 'clicked docs', when the button is clicked
|
||||
* // => logs 'clicked docs', when the button is clicked
|
||||
*/
|
||||
function bindAll(object) {
|
||||
var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object),
|
||||
@@ -3416,11 +3445,22 @@
|
||||
* @returns {Function} Returns the new composed function.
|
||||
* @example
|
||||
*
|
||||
* var greet = function(name) { return 'hi ' + name; };
|
||||
* var exclaim = function(statement) { return statement + '!'; };
|
||||
* var welcome = _.compose(exclaim, greet);
|
||||
* welcome('moe');
|
||||
* // => 'hi moe!'
|
||||
* var realNameMap = {
|
||||
* 'curly': 'jerome'
|
||||
* };
|
||||
*
|
||||
* var format = function(name) {
|
||||
* name = realNameMap[name.toLowerCase()] || name;
|
||||
* return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
||||
* };
|
||||
*
|
||||
* var greet = function(formatted) {
|
||||
* return 'Hiya ' + formatted + '!';
|
||||
* };
|
||||
*
|
||||
* var welcome = _.compose(greet, format);
|
||||
* welcome('curly');
|
||||
* // => 'Hiya Jerome!'
|
||||
*/
|
||||
function compose() {
|
||||
var funcs = arguments;
|
||||
@@ -3660,8 +3700,8 @@
|
||||
* @returns {Number} Returns the timer id.
|
||||
* @example
|
||||
*
|
||||
* _.defer(function() { alert('deferred'); });
|
||||
* // returns from the function before `alert` is called
|
||||
* _.defer(function() { console.log('deferred'); });
|
||||
* // returns from the function before 'deferred' is logged
|
||||
*/
|
||||
function defer(func) {
|
||||
var args = nativeSlice.call(arguments, 1);
|
||||
@@ -4274,10 +4314,10 @@
|
||||
*
|
||||
* _([1, 2, 3, 4])
|
||||
* .filter(function(num) { return num % 2 == 0; })
|
||||
* .tap(alert)
|
||||
* .tap(function(array) { console.log(array); })
|
||||
* .map(function(num) { return num * num; })
|
||||
* .value();
|
||||
* // => // [2, 4] (alerted)
|
||||
* // => // [2, 4] (logged)
|
||||
* // => [4, 16]
|
||||
*/
|
||||
function tap(value, interceptor) {
|
||||
@@ -4344,6 +4384,7 @@
|
||||
lodash.after = after;
|
||||
lodash.bind = bind;
|
||||
lodash.bindAll = bindAll;
|
||||
lodash.chain = chain;
|
||||
lodash.compact = compact;
|
||||
lodash.compose = compose;
|
||||
lodash.countBy = countBy;
|
||||
@@ -4400,9 +4441,6 @@
|
||||
lodash.tail = rest;
|
||||
lodash.unique = uniq;
|
||||
|
||||
// add Underscore compat
|
||||
lodash.chain = chain;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// add functions that return unwrapped values when chaining
|
||||
|
||||
Reference in New Issue
Block a user