mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Rebuild files.
Former-commit-id: ab61934d0b097036dc4cab968d92bfd1450fe8c7
This commit is contained in:
75
dist/lodash.js
vendored
75
dist/lodash.js
vendored
@@ -193,6 +193,7 @@
|
||||
|
||||
/* Native method shortcuts for methods with the same name as other `lodash` methods */
|
||||
var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind,
|
||||
nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate,
|
||||
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
|
||||
nativeIsFinite = context.isFinite,
|
||||
nativeIsNaN = context.isNaN,
|
||||
@@ -240,8 +241,8 @@
|
||||
* `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
|
||||
* `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`,
|
||||
* `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`,
|
||||
* `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `unzip`,
|
||||
* `values`, `where`, `without`, `wrap`, and `zip`
|
||||
* `tap`, `throttle`, `times`, `toArray`, `transform`, `union`, `uniq`, `unshift`,
|
||||
* `unzip`, `values`, `where`, `without`, `wrap`, and `zip`
|
||||
*
|
||||
* The non-chainable wrapper functions are:
|
||||
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`,
|
||||
@@ -487,9 +488,7 @@
|
||||
}
|
||||
if (this instanceof bound) {
|
||||
// ensure `new bound` is an instance of `func`
|
||||
noop.prototype = func.prototype;
|
||||
thisBinding = new noop;
|
||||
noop.prototype = null;
|
||||
thisBinding = createObject(func.prototype);
|
||||
|
||||
// mimic the constructor's `return` behavior
|
||||
// http://es5.github.com/#x13.2.2
|
||||
@@ -501,6 +500,17 @@
|
||||
return bound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new object with the specified `prototype`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} prototype The prototype object.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function createObject(prototype) {
|
||||
return isObject(prototype) ? nativeCreate(prototype) : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by `template` to escape characters for inclusion in compiled
|
||||
* string literals.
|
||||
@@ -1942,6 +1952,56 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms an `object` to an new `accumulator` object which is the result
|
||||
* of running each of its elements through the `callback`, with each `callback`
|
||||
* execution potentially mutating the `accumulator` object. The `callback`is
|
||||
* bound to `thisArg` and invoked with four arguments; (accumulator, value, key, object).
|
||||
* Callbacks may exit iteration early by explicitly returning `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [callback=identity] The function called per iteration.
|
||||
* @param {Mixed} [accumulator] The custom accumulator value.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Mixed} Returns the accumulated value.
|
||||
* @example
|
||||
*
|
||||
* var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(result, num) {
|
||||
* num *= num;
|
||||
* if (num % 2) {
|
||||
* return result.push(num) < 3;
|
||||
* }
|
||||
* });
|
||||
* // => [1, 9, 25]
|
||||
*
|
||||
* var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
|
||||
* result[key] = num * 3;
|
||||
* });
|
||||
* // => { 'a': 3, 'b': 6, 'c': 9 }
|
||||
*/
|
||||
function transform(object, callback, accumulator, thisArg) {
|
||||
var isArr = isArray(object);
|
||||
callback = lodash.createCallback(callback, thisArg, 4);
|
||||
|
||||
if (arguments.length < 3) {
|
||||
if (isArr) {
|
||||
accumulator = [];
|
||||
} else {
|
||||
var ctor = object && object.constructor,
|
||||
proto = ctor && ctor.prototype;
|
||||
|
||||
accumulator = createObject(proto);
|
||||
}
|
||||
}
|
||||
(isArr ? each : forOwn)(object, function(value, index, object) {
|
||||
return callback(accumulator, value, index, object);
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array composed of the own enumerable property values of `object`.
|
||||
*
|
||||
@@ -4218,7 +4278,7 @@
|
||||
if (options === true) {
|
||||
var leading = true;
|
||||
trailing = false;
|
||||
} else if (options && objectTypes[typeof options]) {
|
||||
} else if (isObject(options)) {
|
||||
leading = options.leading;
|
||||
trailing = 'trailing' in options ? options.trailing : trailing;
|
||||
}
|
||||
@@ -4447,7 +4507,7 @@
|
||||
}
|
||||
if (options === false) {
|
||||
leading = false;
|
||||
} else if (options && objectTypes[typeof options]) {
|
||||
} else if (isObject(options)) {
|
||||
leading = 'leading' in options ? options.leading : leading;
|
||||
trailing = 'trailing' in options ? options.trailing : trailing;
|
||||
}
|
||||
@@ -5055,6 +5115,7 @@
|
||||
lodash.throttle = throttle;
|
||||
lodash.times = times;
|
||||
lodash.toArray = toArray;
|
||||
lodash.transform = transform;
|
||||
lodash.union = union;
|
||||
lodash.uniq = uniq;
|
||||
lodash.unzip = unzip;
|
||||
|
||||
Reference in New Issue
Block a user