From 29e1ba38f6d16b17e4b6b7805be8e1be2d27cb83 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Mon, 1 Oct 2012 13:20:03 -0400 Subject: [PATCH] Underscore.js 1.4.1 --- docs/underscore.html | 13 ++++++++----- index.html | 15 ++++++++++++--- package.json | 2 +- underscore-min.js | 4 ++-- underscore.js | 4 ++-- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/docs/underscore.html b/docs/underscore.html index 83858ffd1..976d41eba 100644 --- a/docs/underscore.html +++ b/docs/underscore.html @@ -1,4 +1,4 @@ - underscore.js

underscore.js

Underscore.js 1.4.0
+      underscore.js               
         
     

underscore.js

Underscore.js 1.4.1
 http://underscorejs.org
 (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
 Underscore may be freely distributed under the MIT license.
@@ -34,7 +34,7 @@
     exports._ = _;
   } else {
     root['_'] = _;
-  }

Current version.

  _.VERSION = '1.4.0';

Collection Functions

The cornerstone, an each implementation, aka forEach. + }

Current version.

  _.VERSION = '1.4.1';

Collection Functions

The cornerstone, an each implementation, aka forEach. Handles objects with the built-in forEach, arrays, and raw objects. Delegates to ECMAScript 5's native forEach if available.

  var each = _.each = _.forEach = function(obj, iterator, context) {
     if (nativeForEach && obj.forEach === nativeForEach) {
@@ -358,9 +358,12 @@
     if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
     for (; i < l; i++) if (array[i] === item) return i;
     return -1;
-  };

Delegates to ECMAScript 5's native lastIndexOf if available.

  _.lastIndexOf = function(array, item, fromIndex) {
-    if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item, fromIndex);
-    var i = (fromIndex != null ? fromIndex : array.length);
+  };

Delegates to ECMAScript 5's native lastIndexOf if available.

  _.lastIndexOf = function(array, item, from) {
+    var hasIndex = from != null;
+    if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
+      return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
+    }
+    var i = (hasIndex ? from : array.length);
     while (i--) if (array[i] === item) return i;
     return -1;
   };

Generate an integer Array containing an arithmetic progression. A port of diff --git a/index.html b/index.html index 01e8a06ef..dec084ce8 100644 --- a/index.html +++ b/index.html @@ -179,7 +179,7 @@