mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Bump to v3.3.0.
This commit is contained in:
@@ -40,22 +40,26 @@ var baseClone = require('../internal/baseClone'),
|
||||
* // => false
|
||||
*
|
||||
* // using a customizer callback
|
||||
* var body = _.clone(document.body, function(value) {
|
||||
* return _.isElement(value) ? value.cloneNode(false) : undefined;
|
||||
* var el = _.clone(document.body, function(value) {
|
||||
* if (_.isElement(value)) {
|
||||
* return value.cloneNode(false);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* body === document.body
|
||||
* el === document.body
|
||||
* // => false
|
||||
* body.nodeName
|
||||
* el.nodeName
|
||||
* // => BODY
|
||||
* body.childNodes.length;
|
||||
* el.childNodes.length;
|
||||
* // => 0
|
||||
*/
|
||||
function clone(value, isDeep, customizer, thisArg) {
|
||||
// Juggle arguments.
|
||||
if (typeof isDeep != 'boolean' && isDeep != null) {
|
||||
if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
|
||||
isDeep = false;
|
||||
}
|
||||
else if (typeof isDeep == 'function') {
|
||||
thisArg = customizer;
|
||||
customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep;
|
||||
customizer = isDeep;
|
||||
isDeep = false;
|
||||
}
|
||||
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
|
||||
|
||||
@@ -34,14 +34,16 @@ var baseClone = require('../internal/baseClone'),
|
||||
*
|
||||
* // using a customizer callback
|
||||
* var el = _.cloneDeep(document.body, function(value) {
|
||||
* return _.isElement(value) ? value.cloneNode(true) : undefined;
|
||||
* if (_.isElement(value)) {
|
||||
* return value.cloneNode(true);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* body === document.body
|
||||
* el === document.body
|
||||
* // => false
|
||||
* body.nodeName
|
||||
* el.nodeName
|
||||
* // => BODY
|
||||
* body.childNodes.length;
|
||||
* el.childNodes.length;
|
||||
* // => 20
|
||||
*/
|
||||
function cloneDeep(value, customizer, thisArg) {
|
||||
|
||||
@@ -24,7 +24,7 @@ var objToString = objectProto.toString;
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* (function() { return _.isArguments(arguments); })();
|
||||
* _.isArguments(function() { return arguments; }());
|
||||
* // => true
|
||||
*
|
||||
* _.isArguments([1, 2, 3]);
|
||||
|
||||
@@ -31,7 +31,7 @@ var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray;
|
||||
* _.isArray([1, 2, 3]);
|
||||
* // => true
|
||||
*
|
||||
* (function() { return _.isArray(arguments); })();
|
||||
* _.isArray(function() { return arguments; }());
|
||||
* // => false
|
||||
*/
|
||||
var isArray = nativeIsArray || function(value) {
|
||||
|
||||
@@ -39,7 +39,9 @@ var baseIsEqual = require('../internal/baseIsEqual'),
|
||||
* var other = ['hi', 'goodbye'];
|
||||
*
|
||||
* _.isEqual(array, other, function(value, other) {
|
||||
* return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined;
|
||||
* if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) {
|
||||
* return true;
|
||||
* }
|
||||
* });
|
||||
* // => true
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var isNative = require('./isNative');
|
||||
var baseIsFunction = require('../internal/baseIsFunction'),
|
||||
isNative = require('./isNative');
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var funcTag = '[object Function]';
|
||||
@@ -32,19 +33,11 @@ var Uint8Array = isNative(Uint8Array = global.Uint8Array) && Uint8Array;
|
||||
* _.isFunction(/abc/);
|
||||
* // => false
|
||||
*/
|
||||
function isFunction(value) {
|
||||
// Avoid a Chakra JIT bug in compatibility modes of IE 11.
|
||||
// See https://github.com/jashkenas/underscore/issues/1621 for more details.
|
||||
return typeof value == 'function' || false;
|
||||
}
|
||||
// Fallback for environments that return incorrect `typeof` operator results.
|
||||
if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) {
|
||||
isFunction = function(value) {
|
||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||
// in older versions of Chrome and Safari which return 'function' for regexes
|
||||
// and Safari 8 equivalents which return 'object' for typed array constructors.
|
||||
return objToString.call(value) == funcTag;
|
||||
};
|
||||
}
|
||||
var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
|
||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||
// in older versions of Chrome and Safari which return 'function' for regexes
|
||||
// and Safari 8 equivalents which return 'object' for typed array constructors.
|
||||
return objToString.call(value) == funcTag;
|
||||
};
|
||||
|
||||
module.exports = isFunction;
|
||||
|
||||
@@ -12,7 +12,9 @@ var arrayCopy = require('../internal/arrayCopy'),
|
||||
* @returns {Array} Returns the converted array.
|
||||
* @example
|
||||
*
|
||||
* (function() { return _.toArray(arguments).slice(1); })(1, 2, 3);
|
||||
* (function() {
|
||||
* return _.toArray(arguments).slice(1);
|
||||
* }(1, 2, 3));
|
||||
* // => [2, 3]
|
||||
*/
|
||||
function toArray(value) {
|
||||
|
||||
Reference in New Issue
Block a user