mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -9,12 +9,12 @@ import isIterateeCall from '../internal/isIterateeCall';
|
||||
* cloning is handled by the method instead. The `customizer` is bound to
|
||||
* `thisArg` and invoked with two argument; (value [, index|key, object]).
|
||||
*
|
||||
* **Note:** This method is loosely based on the structured clone algorithm.
|
||||
* **Note:** This method is loosely based on the
|
||||
* [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
|
||||
* The enumerable properties of `arguments` objects and objects created by
|
||||
* constructors other than `Object` are cloned to plain `Object` objects. An
|
||||
* empty object is returned for uncloneable values such as functions, DOM nodes,
|
||||
* Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
|
||||
* for more details.
|
||||
* Maps, Sets, and WeakMaps.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -7,12 +7,12 @@ import bindCallback from '../internal/bindCallback';
|
||||
* is handled by the method instead. The `customizer` is bound to `thisArg`
|
||||
* and invoked with two argument; (value [, index|key, object]).
|
||||
*
|
||||
* **Note:** This method is loosely based on the structured clone algorithm.
|
||||
* **Note:** This method is loosely based on the
|
||||
* [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
|
||||
* The enumerable properties of `arguments` objects and objects created by
|
||||
* constructors other than `Object` are cloned to plain `Object` objects. An
|
||||
* empty object is returned for uncloneable values such as functions, DOM nodes,
|
||||
* Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
|
||||
* for more details.
|
||||
* Maps, Sets, and WeakMaps.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -8,9 +8,8 @@ var argsTag = '[object Arguments]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -32,7 +31,7 @@ var objToString = objectProto.toString;
|
||||
*/
|
||||
function isArguments(value) {
|
||||
var length = isObjectLike(value) ? value.length : undefined;
|
||||
return (isLength(length) && objToString.call(value) == argsTag) || false;
|
||||
return isLength(length) && objToString.call(value) == argsTag;
|
||||
}
|
||||
|
||||
export default isArguments;
|
||||
|
||||
@@ -9,9 +9,8 @@ var arrayTag = '[object Array]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -35,7 +34,7 @@ var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray;
|
||||
* // => false
|
||||
*/
|
||||
var isArray = nativeIsArray || function(value) {
|
||||
return (isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag) || false;
|
||||
return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
|
||||
};
|
||||
|
||||
export default isArray;
|
||||
|
||||
@@ -7,9 +7,8 @@ var boolTag = '[object Boolean]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -30,7 +29,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isBoolean(value) {
|
||||
return (value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag) || false;
|
||||
return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag);
|
||||
}
|
||||
|
||||
export default isBoolean;
|
||||
|
||||
@@ -7,9 +7,8 @@ var dateTag = '[object Date]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -30,7 +29,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isDate(value) {
|
||||
return (isObjectLike(value) && objToString.call(value) == dateTag) || false;
|
||||
return isObjectLike(value) && objToString.call(value) == dateTag;
|
||||
}
|
||||
|
||||
export default isDate;
|
||||
|
||||
@@ -6,9 +6,8 @@ import support from '../support';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -29,13 +28,13 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isElement(value) {
|
||||
return (value && value.nodeType === 1 && isObjectLike(value) &&
|
||||
(objToString.call(value).indexOf('Element') > -1)) || false;
|
||||
return !!value && value.nodeType === 1 && isObjectLike(value) &&
|
||||
(objToString.call(value).indexOf('Element') > -1);
|
||||
}
|
||||
// Fallback for environments without DOM support.
|
||||
if (!support.dom) {
|
||||
isElement = function(value) {
|
||||
return (value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value)) || false;
|
||||
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import isStrictComparable from '../internal/isStrictComparable';
|
||||
* equivalent. If `customizer` is provided it is invoked to compare values.
|
||||
* If `customizer` returns `undefined` comparisons are handled by the method
|
||||
* instead. The `customizer` is bound to `thisArg` and invoked with three
|
||||
* arguments; (value, other [, index|key]).
|
||||
* arguments: (value, other [, index|key]).
|
||||
*
|
||||
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
|
||||
* numbers, `Object` objects, regexes, and strings. Objects are compared by
|
||||
|
||||
@@ -7,9 +7,8 @@ var errorTag = '[object Error]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -31,7 +30,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isError(value) {
|
||||
return (isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag) || false;
|
||||
return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag;
|
||||
}
|
||||
|
||||
export default isError;
|
||||
|
||||
@@ -8,9 +8,7 @@ var nativeIsFinite = root.isFinite,
|
||||
/**
|
||||
* Checks if `value` is a finite primitive number.
|
||||
*
|
||||
* **Note:** This method is based on ES `Number.isFinite`. See the
|
||||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite)
|
||||
* for more details.
|
||||
* **Note:** This method is based on [`Number.isFinite`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -9,9 +9,8 @@ var funcTag = '[object Function]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
|
||||
@@ -2,19 +2,14 @@ import baseIsMatch from '../internal/baseIsMatch';
|
||||
import bindCallback from '../internal/bindCallback';
|
||||
import isStrictComparable from '../internal/isStrictComparable';
|
||||
import keys from '../object/keys';
|
||||
|
||||
/** Used for native method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
import toObject from '../internal/toObject';
|
||||
|
||||
/**
|
||||
* Performs a deep comparison between `object` and `source` to determine if
|
||||
* `object` contains equivalent property values. If `customizer` is provided
|
||||
* it is invoked to compare values. If `customizer` returns `undefined`
|
||||
* comparisons are handled by the method instead. The `customizer` is bound
|
||||
* to `thisArg` and invoked with three arguments; (value, other, index|key).
|
||||
* to `thisArg` and invoked with three arguments: (value, other, index|key).
|
||||
*
|
||||
* **Note:** This method supports comparing properties of arrays, booleans,
|
||||
* `Date` objects, numbers, `Object` objects, regexes, and strings. Functions
|
||||
@@ -52,13 +47,19 @@ function isMatch(object, source, customizer, thisArg) {
|
||||
var props = keys(source),
|
||||
length = props.length;
|
||||
|
||||
if (!length) {
|
||||
return true;
|
||||
}
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3);
|
||||
if (!customizer && length == 1) {
|
||||
var key = props[0],
|
||||
value = source[key];
|
||||
|
||||
if (isStrictComparable(value)) {
|
||||
return object != null && value === object[key] && hasOwnProperty.call(object, key);
|
||||
return value === object[key] && (typeof value != 'undefined' || (key in toObject(object)));
|
||||
}
|
||||
}
|
||||
var values = Array(length),
|
||||
@@ -68,7 +69,7 @@ function isMatch(object, source, customizer, thisArg) {
|
||||
value = values[length] = source[props[length]];
|
||||
strictCompareFlags[length] = isStrictComparable(value);
|
||||
}
|
||||
return baseIsMatch(object, props, values, strictCompareFlags, customizer);
|
||||
return baseIsMatch(toObject(object), props, values, strictCompareFlags, customizer);
|
||||
}
|
||||
|
||||
export default isMatch;
|
||||
|
||||
@@ -3,9 +3,8 @@ import isNumber from './isNumber';
|
||||
/**
|
||||
* Checks if `value` is `NaN`.
|
||||
*
|
||||
* **Note:** This method is not the same as native `isNaN` which returns `true`
|
||||
* for `undefined` and other non-numeric values. See the [ES5 spec](https://es5.github.io/#x15.1.2.4)
|
||||
* for more details.
|
||||
* **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4)
|
||||
* which returns `true` for `undefined` and other non-numeric values.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -14,9 +14,8 @@ var objectProto = Object.prototype;
|
||||
var fnToString = Function.prototype.toString;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -49,7 +48,7 @@ function isNative(value) {
|
||||
if (objToString.call(value) == funcTag) {
|
||||
return reNative.test(fnToString.call(value));
|
||||
}
|
||||
return (isObjectLike(value) && reHostCtor.test(value)) || false;
|
||||
return isObjectLike(value) && reHostCtor.test(value);
|
||||
}
|
||||
|
||||
export default isNative;
|
||||
|
||||
@@ -7,9 +7,8 @@ var numberTag = '[object Number]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -36,7 +35,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isNumber(value) {
|
||||
return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag) || false;
|
||||
return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
|
||||
}
|
||||
|
||||
export default isNumber;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* Checks if `value` is the language type of `Object`.
|
||||
* 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('')`)
|
||||
*
|
||||
* **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
@@ -24,7 +22,7 @@ function isObject(value) {
|
||||
// Avoid a V8 JIT bug in Chrome 19-20.
|
||||
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
|
||||
var type = typeof value;
|
||||
return type == 'function' || (value && type == 'object') || false;
|
||||
return type == 'function' || (!!value && type == 'object');
|
||||
}
|
||||
|
||||
export default isObject;
|
||||
|
||||
@@ -8,9 +8,8 @@ var objectTag = '[object Object]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@ var regexpTag = '[object RegExp]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@ var stringTag = '[object String]';
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -30,7 +29,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isString(value) {
|
||||
return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag) || false;
|
||||
return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
|
||||
}
|
||||
|
||||
export default isString;
|
||||
|
||||
@@ -46,9 +46,8 @@ typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the `toStringTag` of values.
|
||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* for more details.
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
@@ -69,7 +68,7 @@ var objToString = objectProto.toString;
|
||||
* // => false
|
||||
*/
|
||||
function isTypedArray(value) {
|
||||
return (isObjectLike(value) && isLength(value.length) && typedArrayTags[objToString.call(value)]) || false;
|
||||
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
|
||||
}
|
||||
|
||||
export default isTypedArray;
|
||||
|
||||
Reference in New Issue
Block a user