// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
- var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null;
// Create quick reference variables for speed access to core prototypes.
var push = ArrayProto.push,
// Return the first value which passes a truth test. Aliased as `detect`.
_.find = _.detect = function(obj, predicate, context) {
- var keyFinder = isArrayLike(obj) ? _.findIndex : _.findKey;
- var key = keyFinder(obj, predicate, context);
+ var key;
+ if (isArrayLike(obj)) {
+ key = _.findIndex(obj, predicate, context);
+ } else {
+ key = _.findKey(obj, predicate, context);
+ }
if (key !== void 0 && key !== -1) return obj[key];
};
// Keep surrogate pair characters together
return obj.match(reStrSymbol);
}
- if (isArrayLike(obj)) return _.map(obj);
+ if (isArrayLike(obj)) return _.map(obj, _.identity);
return _.values(obj);
};
// Trim out all falsy values from an array.
_.compact = function(array) {
- return _.filter(array);
+ return _.filter(array, _.identity);
};
// Internal implementation of a recursive `flatten` function.
};
var debounced = restArgs(function(args) {
+ var callNow = immediate && !timeout;
if (timeout) clearTimeout(timeout);
- if (immediate) {
- var callNow = !timeout;
+ if (callNow) {
timeout = setTimeout(later, wait);
- if (callNow) result = func.apply(this, args);
- } else {
+ result = func.apply(this, args);
+ } else if (!immediate) {
timeout = _.delay(later, wait, this, args);
}
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a === +b;
- case '[object Symbol]':
- return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
}
var areArrays = className === '[object Array]';
return type === 'function' || type === 'object' && !!obj;
};
- // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError, isMap, isWeakMap, isSet, isWeakSet.
- _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet'], function(name) {
+ // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
+ _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol'], function(name) {
_['is' + name] = function(obj) {
return toString.call(obj) === '[object ' + name + ']';
};