underscore-source 0.6.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Underscore
2
2
  module Source
3
- VERSION = "0.6.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -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 reference below.
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.6.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 criteria produced by an iterator.
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 of the properties in a source object.
437
- _.extend = function(destination, source) {
438
- for (var property in source) destination[property] = source[property];
439
- return destination;
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);
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: underscore-source
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.0
5
+ version: 1.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel X. Moore