vendor/assets/javascripts/lodash.core.js in lodash-rails-4.3.0 vs vendor/assets/javascripts/lodash.core.js in lodash-rails-4.5.1
- old
+ new
@@ -1,8 +1,8 @@
/**
* @license
- * lodash 4.3.0 (Custom Build) <https://lodash.com/>
+ * lodash 4.5.1 (Custom Build) <https://lodash.com/>
* Build: `lodash core -o ./dist/lodash.core.js`
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
@@ -11,11 +11,11 @@
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the semantic version number. */
- var VERSION = '4.3.0';
+ var VERSION = '4.5.1';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
PARTIAL_FLAG = 32;
@@ -25,11 +25,12 @@
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
+ var INFINITY = 1 / 0,
+ MAX_SAFE_INTEGER = 9007199254740991;
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
arrayTag = '[object Array]',
boolTag = '[object Boolean]',
@@ -64,37 +65,45 @@
'function': true,
'object': true
};
/** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
+ var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
+ ? exports
+ : undefined;
/** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
+ var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
+ ? module
+ : undefined;
+ /** Detect the popular CommonJS extension `module.exports`. */
+ var moduleExports = (freeModule && freeModule.exports === freeExports)
+ ? freeExports
+ : undefined;
+
/** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
/** Detect free variable `self`. */
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
/** Detect free variable `window`. */
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
-
/** Detect `this` as the global object. */
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
/**
* Used as a reference to the global object.
*
* The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
- var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
+ var root = freeGlobal ||
+ ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
+ freeSelf || thisGlobal || Function('return this')();
/*--------------------------------------------------------------------------*/
/**
* Creates a new array concatenating `array` with `other`.
@@ -363,10 +372,11 @@
/** Built-in value references. */
var Reflect = root.Reflect,
Symbol = root.Symbol,
Uint8Array = root.Uint8Array,
enumerate = Reflect ? Reflect.enumerate : undefined,
+ objectCreate = Object.create,
propertyIsEnumerable = objectProto.propertyIsEnumerable;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeIsFinite = root.isFinite,
nativeKeys = Object.keys,
@@ -411,55 +421,56 @@
* `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
* `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
*
* The chainable wrapper methods are:
- * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
- * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
- * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
- * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
- * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
- * `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
- * `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`,
- * `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
- * `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
- * `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`,
- * `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`,
- * `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`,
- * `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`,
- * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`,
- * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`,
- * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
- * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
- * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
- * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
- * `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
- * `zipObjectDeep`, and `zipWith`
+ * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flattenDepth`,
+ * `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`,
+ * `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`,
+ * `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`,
+ * `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`,
+ * `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`,
+ * `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`,
+ * `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`,
+ * `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`,
+ * `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
+ * `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
+ * `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
+ * `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`,
+ * `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
+ * `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
+ * `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
+ * `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, and `zipWith`
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`,
- * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
- * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`,
- * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
- * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
- * `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
- * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`,
- * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`,
- * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`,
- * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`,
- * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`,
- * `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`,
- * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
- * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
- * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
- * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
- * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toLower`,
- * `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`,
- * `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`,
- * `upperCase`, `upperFirst`, `value`, and `words`
+ * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
+ * `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`, `forIn`,
+ * `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`,
+ * `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`,
+ * `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
+ * `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
+ * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`,
+ * `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
+ * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`,
+ * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
+ * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
+ * `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`, `noConflict`, `noop`,
+ * `now`, `pad`, `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`,
+ * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `sample`,
+ * `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`,
+ * `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, `startsWith`, `subtract`,
+ * `sum`, `sumBy`, `template`, `times`, `toLower`, `toInteger`, `toLength`,
+ * `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`,
+ * `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`,
+ * `value`, and `words`
*
* @name _
* @constructor
* @category Seq
* @param {*} value The value to wrap in a `lodash` instance.
@@ -540,36 +551,38 @@
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
- if ((!eq(objValue, value) ||
- (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
+ if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) {
object[key] = value;
}
}
/**
+ * Casts `value` to `identity` if it's not a function.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Array} Returns the array-like object.
+ */
+ function baseCastFunction(value) {
+ return typeof value == 'function' ? value : identity;
+ }
+
+ /**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object.
*/
- var baseCreate = (function() {
- function object() {}
- return function(prototype) {
- if (isObject(prototype)) {
- object.prototype = prototype;
- var result = new object;
- object.prototype = undefined;
- }
- return result || {};
- };
- }());
+ function baseCreate(proto) {
+ return isObject(proto) ? objectCreate(proto) : {};
+ }
/**
* The base implementation of `_.delay` and `_.defer` which accepts an array
* of `func` arguments.
*
@@ -634,28 +647,28 @@
/**
* The base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {Array} array The array to flatten.
- * @param {boolean} [isDeep] Specify a deep flatten.
+ * @param {number} depth The maximum recursion depth.
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
- function baseFlatten(array, isDeep, isStrict, result) {
+ function baseFlatten(array, depth, isStrict, result) {
result || (result = []);
var index = -1,
length = array.length;
while (++index < length) {
var value = array[index];
- if (isArrayLikeObject(value) &&
+ if (depth > 0 && isArrayLikeObject(value) &&
(isStrict || isArray(value) || isArguments(value))) {
- if (isDeep) {
+ if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
- baseFlatten(value, isDeep, isStrict, result);
+ baseFlatten(value, depth - 1, isStrict, result);
} else {
arrayPush(result, value);
}
} else if (!isStrict) {
result[result.length] = value;
@@ -814,11 +827,10 @@
/**
* The base implementation of `_.keys` which doesn't skip the constructor
* property of prototypes or treat sparse arrays as dense.
*
* @private
- * @type Function
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
return nativeKeys(Object(object));
@@ -1030,13 +1042,16 @@
var index = -1,
length = props.length;
while (++index < length) {
- var key = props[index],
- newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
+ var key = props[index];
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : source[key];
+
assignValue(object, key, newValue);
}
return object;
}
@@ -1051,11 +1066,14 @@
return rest(function(object, sources) {
var index = -1,
length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined;
- customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
+ customizer = typeof customizer == 'function'
+ ? (length--, customizer)
+ : undefined;
+
object = Object(object);
while (++index < length) {
var source = sources[index];
if (source) {
assigner(object, source, index, customizer);
@@ -1375,27 +1393,16 @@
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
+ proto = (isFunction(Ctor) && Ctor.prototype) || objectProto;
return value === proto;
}
/**
- * Converts `value` to a function if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Function} Returns the function.
- */
- function toFunction(value) {
- return typeof value == 'function' ? value : identity;
- }
-
- /**
* Creates a clone of `wrapper`.
*
* @private
* @param {Object} wrapper The wrapper to clone.
* @returns {Object} Returns the cloned wrapper.
@@ -1449,48 +1456,48 @@
*/
var concat = rest(function(array, values) {
if (!isArray(array)) {
array = array == null ? [] : [Object(array)];
}
- values = baseFlatten(values);
+ values = baseFlatten(values, 1);
return arrayConcat(array, values);
});
/**
- * Flattens `array` a single level.
+ * Flattens `array` a single level deep.
*
* @static
* @memberOf _
* @category Array
* @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
- * _.flatten([1, [2, 3, [4]]]);
- * // => [1, 2, 3, [4]]
+ * _.flatten([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array ? array.length : 0;
- return length ? baseFlatten(array) : [];
+ return length ? baseFlatten(array, 1) : [];
}
/**
- * This method is like `_.flatten` except that it recursively flattens `array`.
+ * Recursively flattens `array`.
*
* @static
* @memberOf _
* @category Array
- * @param {Array} array The array to recursively flatten.
+ * @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
- * _.flattenDeep([1, [2, 3, [4]]]);
- * // => [1, 2, 3, 4]
+ * _.flattenDeep([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, 3, 4, 5]
*/
function flattenDeep(array) {
var length = array ? array.length : 0;
- return length ? baseFlatten(array, true) : [];
+ return length ? baseFlatten(array, INFINITY) : [];
}
/**
* Gets the first element of `array`.
*
@@ -1870,11 +1877,11 @@
* console.log(key);
* });
* // => logs 'a' then 'b' (iteration order is not guaranteed)
*/
function forEach(collection, iteratee) {
- return baseEach(collection, toFunction(iteratee));
+ return baseEach(collection, baseCastFunction(iteratee));
}
/**
* Creates an array of values by running each element in `collection` through
* `iteratee`. The iteratee is invoked with three arguments:
@@ -2398,11 +2405,11 @@
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
- * @type Function
+ * @type {Function}
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
* @example
*
@@ -2425,11 +2432,10 @@
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
@@ -2454,11 +2460,10 @@
* This method is like `_.isArrayLike` except that it also checks if `value`
* is an object.
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
* @example
*
@@ -2546,11 +2551,12 @@
* _.isEmpty({ 'a': 1 });
* // => false
*/
function isEmpty(value) {
if (isArrayLike(value) &&
- (isArray(value) || isString(value) || isFunction(value.splice) || isArguments(value))) {
+ (isArray(value) || isString(value) ||
+ isFunction(value.splice) || isArguments(value))) {
return !value.length;
}
for (var key in value) {
if (hasOwnProperty.call(value, key)) {
return false;
@@ -2665,11 +2671,12 @@
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
/**
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
@@ -3293,11 +3300,11 @@
*
* _.pick(object, ['a', 'c']);
* // => { 'a': 1, 'c': 3 }
*/
var pick = rest(function(object, props) {
- return object == null ? {} : basePick(object, baseFlatten(props));
+ return object == null ? {} : basePick(object, baseFlatten(props, 1));
});
/**
* This method is like `_.get` except that if the resolved value is a function
* it's invoked with the `this` binding of its parent object and its result
@@ -3427,11 +3434,12 @@
/**
* Creates a function that invokes `func` with the arguments of the created
* function. If `func` is a property name the created callback returns the
* property value for a given element. If `func` is an object the created
- * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
+ * callback returns `true` for elements that contain the equivalent object
+ * properties, otherwise it returns `false`.
*
* @static
* @memberOf _
* @category Util
* @param {*} [func=_.identity] The value to convert to a callback.
@@ -3455,13 +3463,14 @@
* // => [{ 'user': 'fred', 'age': 40 }]
*/
var iteratee = baseIteratee;
/**
- * Creates a function that performs a deep partial comparison between a given
+ * Creates a function that performs a partial deep comparison between a given
* object and `source`, returning `true` if the given object has equivalent
- * property values, else `false`.
+ * property values, else `false`. The created function is equivalent to
+ * `_.isMatch` with a `source` partially applied.
*
* **Note:** This method supports comparing the same values as `_.isEqual`.
*
* @static
* @memberOf _
@@ -3595,11 +3604,11 @@
* Generates a unique ID. If `prefix` is given the ID is appended to it.
*
* @static
* @memberOf _
* @category Util
- * @param {string} [prefix] The value to prefix the ID with.
+ * @param {string} [prefix=''] The value to prefix the ID with.
* @returns {string} Returns the unique ID.
* @example
*
* _.uniqueId('contact_');
* // => 'contact_104'
@@ -3757,10 +3766,10 @@
/**
* The semantic version number.
*
* @static
* @memberOf _
- * @type string
+ * @type {string}
*/
lodash.VERSION = VERSION;
// Add `Array` and `String` methods to `lodash.prototype`.
baseEach(['pop', 'join', 'replace', 'reverse', 'split', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {