mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Reorganize method order.
Former-commit-id: a24a02725595ac28633a24a1f33c152db87dda77
This commit is contained in:
164
lodash.js
164
lodash.js
@@ -757,85 +757,6 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is an array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true` if the `value` is an array, else `false`.
|
||||
* @example
|
||||
*
|
||||
* (function() { return _.isArray(arguments); })();
|
||||
* // => false
|
||||
*
|
||||
* _.isArray([1, 2, 3]);
|
||||
* // => true
|
||||
*/
|
||||
var isArray = nativeIsArray || function(value) {
|
||||
return toString.call(value) == arrayClass;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is a function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true` if the `value` is a function, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isFunction(_);
|
||||
* // => true
|
||||
*/
|
||||
function isFunction(value) {
|
||||
return typeof value == 'function';
|
||||
}
|
||||
// fallback for older versions of Chrome and Safari
|
||||
if (isFunction(/x/)) {
|
||||
isFunction = function(value) {
|
||||
return toString.call(value) == funcClass;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given `value` is an object created by the `Object` constructor.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true` if `value` is a plain object, else `false`.
|
||||
* @example
|
||||
*
|
||||
* function Stooge(name, age) {
|
||||
* this.name = name;
|
||||
* this.age = age;
|
||||
* }
|
||||
*
|
||||
* _.isPlainObject(new Stooge('moe', 40));
|
||||
* // => false
|
||||
*
|
||||
* _.isPlainObject([1, 2, 3]);
|
||||
* // => false
|
||||
*
|
||||
* _.isPlainObject({ 'name': 'moe', 'age': 40 });
|
||||
* // => true
|
||||
*/
|
||||
var isPlainObject = !getPrototypeOf ? isPlainFallback : function(value) {
|
||||
if (!(value && typeof value == 'object')) {
|
||||
return false;
|
||||
}
|
||||
var valueOf = value.valueOf,
|
||||
objProto = typeof valueOf == 'function' && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
|
||||
|
||||
return objProto
|
||||
? value == objProto || (getPrototypeOf(value) == objProto && !isArguments(value))
|
||||
: isPlainFallback(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* A fallback implementation of `isPlainObject` that checks if a given `value`
|
||||
* is an object created by the `Object` constructor, assuming objects created
|
||||
@@ -846,7 +767,7 @@
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true` if `value` is a plain object, else `false`.
|
||||
*/
|
||||
function isPlainFallback(value) {
|
||||
function shimIsPlainObject(value) {
|
||||
// avoid non-objects and false positives for `arguments` objects
|
||||
var result = false;
|
||||
if (!(value && typeof value == 'object') || isArguments(value)) {
|
||||
@@ -880,8 +801,8 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* A shim implementation of `Object.keys` that produces an array of the given
|
||||
* object's own enumerable property names.
|
||||
* A fallback implementation of `Object.keys` that produces an array of the
|
||||
* given object's own enumerable property names.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to inspect.
|
||||
@@ -1122,6 +1043,26 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is an array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true` if the `value` is an array, else `false`.
|
||||
* @example
|
||||
*
|
||||
* (function() { return _.isArray(arguments); })();
|
||||
* // => false
|
||||
*
|
||||
* _.isArray([1, 2, 3]);
|
||||
* // => true
|
||||
*/
|
||||
var isArray = nativeIsArray || function(value) {
|
||||
return toString.call(value) == arrayClass;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is a boolean (`true` or `false`) value.
|
||||
*
|
||||
@@ -1402,6 +1343,29 @@
|
||||
return nativeIsFinite(value ? +value : parseFloat(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true` if the `value` is a function, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isFunction(_);
|
||||
* // => true
|
||||
*/
|
||||
function isFunction(value) {
|
||||
return typeof value == 'function';
|
||||
}
|
||||
// fallback for older versions of Chrome and Safari
|
||||
if (isFunction(/x/)) {
|
||||
isFunction = function(value) {
|
||||
return toString.call(value) == funcClass;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is the language type of Object.
|
||||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
||||
@@ -1500,6 +1464,42 @@
|
||||
return toString.call(value) == numberClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given `value` is an object created by the `Object` constructor.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to check.
|
||||
* @returns {Boolean} Returns `true` if `value` is a plain object, else `false`.
|
||||
* @example
|
||||
*
|
||||
* function Stooge(name, age) {
|
||||
* this.name = name;
|
||||
* this.age = age;
|
||||
* }
|
||||
*
|
||||
* _.isPlainObject(new Stooge('moe', 40));
|
||||
* // => false
|
||||
*
|
||||
* _.isPlainObject([1, 2, 3]);
|
||||
* // => false
|
||||
*
|
||||
* _.isPlainObject({ 'name': 'moe', 'age': 40 });
|
||||
* // => true
|
||||
*/
|
||||
var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
|
||||
if (!(value && typeof value == 'object')) {
|
||||
return false;
|
||||
}
|
||||
var valueOf = value.valueOf,
|
||||
objProto = typeof valueOf == 'function' && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
|
||||
|
||||
return objProto
|
||||
? value == objProto || (getPrototypeOf(value) == objProto && !isArguments(value))
|
||||
: shimIsPlainObject(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is a regular expression.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user