// Underscore.js 1.8.3
// http://underscorejs.org
-// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+// (c) 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
(function() {
return _.property(value);
};
- // An external wrapper for the internal callback generator
+ // An external wrapper for the internal callback generator.
_.iteratee = function(value, context) {
return cb(value, context, Infinity);
};
for (var i = 0, length = getLength(input); i < length; i++) {
var value = input[i];
if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
- // Flatten current level of array or arguments object
+ // Flatten current level of array or arguments object.
if (shallow) {
var j = 0, len = value.length;
while (j < len) output[idx++] = value[j++];
});
// Complement of _.zip. Unzip accepts an array of arrays and groups
- // each array's elements on shared indices
+ // each array's elements on shared indices.
_.unzip = function(array) {
var length = array && _.max(array, getLength).length || 0;
var result = Array(length);
return result;
};
- // Generator function to create the findIndex and findLastIndex functions
+ // Generator function to create the findIndex and findLastIndex functions.
var createPredicateIndexFinder = function(dir) {
return function(array, predicate, context) {
predicate = cb(predicate, context);
};
};
- // Returns the first index on an array-like that passes a predicate test
+ // Returns the first index on an array-like that passes a predicate test.
_.findIndex = createPredicateIndexFinder(1);
_.findLastIndex = createPredicateIndexFinder(-1);
return low;
};
- // Generator function to create the indexOf and lastIndexOf functions
+ // Generator function to create the indexOf and lastIndexOf functions.
var createIndexFinder = function(dir, predicateFind, sortedIndex) {
return function(array, item, idx) {
var i = 0, length = getLength(array);
};
// Split an **array** into several arrays containing **count** or less elements
- // of initial array
+ // of initial array.
_.chunk = function(array, count) {
if (count == null || count < 1) return [];
// ------------------
// Determines whether to execute a function as a constructor
- // or a normal function with the provided arguments
+ // or a normal function with the provided arguments.
var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
var self = baseCreate(sourceFunc.prototype);
};
// Retrieve the names of an object's own properties.
- // Delegates to **ECMAScript 5**'s native `Object.keys`
+ // Delegates to **ECMAScript 5**'s native `Object.keys`.
_.keys = function(obj) {
if (!_.isObject(obj)) return [];
if (nativeKeys) return nativeKeys(obj);
return values;
};
- // Returns the results of applying the iteratee to each element of the object
- // In contrast to _.map it returns an object
+ // Returns the results of applying the iteratee to each element of the object.
+ // In contrast to _.map it returns an object.
_.mapObject = function(obj, iteratee, context) {
iteratee = cb(iteratee, context);
var keys = _.keys(obj),
};
// Return a sorted list of the function names available on the object.
- // Aliased as `methods`
+ // Aliased as `methods`.
_.functions = _.methods = function(obj) {
var names = [];
for (var key in obj) {
// Extend a given object with all the properties in passed-in object(s).
_.extend = createAssigner(_.allKeys);
- // Assigns a given object with all the own properties in the passed-in object(s)
+ // Assigns a given object with all the own properties in the passed-in object(s).
// (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
_.extendOwn = _.assign = createAssigner(_.keys);
- // Returns the first key on an object that passes a predicate test
+ // Returns the first key on an object that passes a predicate test.
_.findKey = function(obj, predicate, context) {
predicate = cb(predicate, context);
var keys = _.keys(obj), key;
return '' + a === '' + b;
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive.
- // Object(NaN) is equivalent to NaN
+ // Object(NaN) is equivalent to NaN.
if (+a !== +a) return +b !== +b;
// An `egal` comparison is performed for other numeric values.
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
};
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
- _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
+ _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol'], function(name) {
_['is' + name] = function(obj) {
return toString.call(obj) === '[object ' + name + ']';
};
// Is a given object a finite number?
_.isFinite = function(obj) {
- return isFinite(obj) && !isNaN(parseFloat(obj));
+ return !_.isSymbol(obj) && isFinite(obj) && !isNaN(parseFloat(obj));
};
// Is the given value `NaN`?
var escaper = function(match) {
return map[match];
};
- // Regexes for identifying a key that needs to be escaped
+ // Regexes for identifying a key that needs to be escaped.
var source = '(?:' + _.keys(map).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');