underscore-source 0.6.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@
|
|
45
45
|
nativeIsArray = Array.isArray,
|
46
46
|
nativeKeys = Object.keys;
|
47
47
|
|
48
|
-
// Create a safe reference to the Underscore object for
|
48
|
+
// Create a safe reference to the Underscore object for use below.
|
49
49
|
var _ = function(obj) { return new wrapper(obj); };
|
50
50
|
|
51
51
|
// Export the Underscore object for CommonJS.
|
@@ -55,7 +55,7 @@
|
|
55
55
|
root._ = _;
|
56
56
|
|
57
57
|
// Current version.
|
58
|
-
_.VERSION = '0.
|
58
|
+
_.VERSION = '1.0.0';
|
59
59
|
|
60
60
|
// ------------------------ Collection Functions: ---------------------------
|
61
61
|
|
@@ -63,7 +63,6 @@
|
|
63
63
|
// Handles objects implementing forEach, arrays, and raw objects.
|
64
64
|
// Delegates to JavaScript 1.6's native forEach if available.
|
65
65
|
var each = _.forEach = function(obj, iterator, context) {
|
66
|
-
var index = 0;
|
67
66
|
try {
|
68
67
|
if (nativeForEach && obj.forEach === nativeForEach) {
|
69
68
|
obj.forEach(iterator, context);
|
@@ -210,7 +209,7 @@
|
|
210
209
|
return result.value;
|
211
210
|
};
|
212
211
|
|
213
|
-
// Sort the object's values by a
|
212
|
+
// Sort the object's values by a criterion produced by an iterator.
|
214
213
|
_.sortBy = function(obj, iterator, context) {
|
215
214
|
return _.pluck(_.map(obj, function(value, index, list) {
|
216
215
|
return {
|
@@ -433,10 +432,12 @@
|
|
433
432
|
return _.filter(_.keys(obj), function(key){ return _.isFunction(obj[key]); }).sort();
|
434
433
|
};
|
435
434
|
|
436
|
-
// Extend a given object with all
|
437
|
-
_.extend = function(
|
438
|
-
|
439
|
-
|
435
|
+
// Extend a given object with all the properties in passed-in object(s).
|
436
|
+
_.extend = function(obj) {
|
437
|
+
each(_.rest(arguments), function(source) {
|
438
|
+
for (var prop in source) obj[prop] = source[prop];
|
439
|
+
});
|
440
|
+
return obj;
|
440
441
|
};
|
441
442
|
|
442
443
|
// Create a (shallow-cloned) duplicate of an object.
|
@@ -526,6 +527,11 @@
|
|
526
527
|
return (obj === +obj) || (toString.call(obj) === '[object Number]');
|
527
528
|
};
|
528
529
|
|
530
|
+
// Is a given value a boolean?
|
531
|
+
_.isBoolean = function(obj) {
|
532
|
+
return obj === true || obj === false;
|
533
|
+
};
|
534
|
+
|
529
535
|
// Is a given value a date?
|
530
536
|
_.isDate = function(obj) {
|
531
537
|
return !!(obj && obj.getTimezoneOffset && obj.setUTCFullYear);
|