Permalink
Browse files

Upgrading to Underscore 1.1.6 for test deps.

  • Loading branch information...
jashkenas committed Apr 18, 2011
1 parent da52ae1 commit 7b494c1e6def093bfb3914ea299c5ab5d0f7a3ab
Showing with 26 additions and 14 deletions.
  1. +1 −1 examples/todos/index.html
  2. +1 −1 index.html
  3. +1 −1 test/test-zepto.html
  4. +1 −1 test/test.html
  5. +22 −10 test/vendor/{underscore-1.1.5.js → underscore-1.1.6.js}
@@ -6,7 +6,7 @@
<link href="todos.css" media="all" rel="stylesheet" type="text/css"/>
<script src="../../test/vendor/json2.js"></script>
<script src="../../test/vendor/jquery-1.5.js"></script>
- <script src="../../test/vendor/underscore-1.1.5.js"></script>
+ <script src="../../test/vendor/underscore-1.1.6.js"></script>
<script src="../../backbone.js"></script>
<script src="../backbone-localstorage.js"></script>
<script src="todos.js"></script>
View
@@ -2255,7 +2255,7 @@ <h2 id="changelog">Change Log</h2>
</div>
- <script src="test/vendor/underscore-1.1.5.js"></script>
+ <script src="test/vendor/underscore-1.1.6.js"></script>
<script src="test/vendor/jquery-1.5.js"></script>
<script src="test/vendor/json2.js"></script>
<script src="backbone.js"></script>
View
@@ -7,7 +7,7 @@
<script type="text/javascript" src="vendor/zepto-0.5.js"></script>
<script type="text/javascript" src="vendor/qunit.js"></script>
<script type="text/javascript" src="vendor/jslitmus.js"></script>
- <script type="text/javascript" src="vendor/underscore-1.1.5.js"></script>
+ <script type="text/javascript" src="vendor/underscore-1.1.6.js"></script>
<script type="text/javascript" src="../backbone.js"></script>
<script type="text/javascript" src="events.js"></script>
View
@@ -7,7 +7,7 @@
<script type="text/javascript" src="vendor/jquery-1.5.js"></script>
<script type="text/javascript" src="vendor/qunit.js"></script>
<script type="text/javascript" src="vendor/jslitmus.js"></script>
- <script type="text/javascript" src="vendor/underscore-1.1.5.js"></script>
+ <script type="text/javascript" src="vendor/underscore-1.1.6.js"></script>
<script type="text/javascript" src="../backbone.js"></script>
<script type="text/javascript" src="events.js"></script>
@@ -1,4 +1,4 @@
-// Underscore.js 1.1.5
+// Underscore.js 1.1.6
// (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
@@ -59,7 +59,7 @@
}
// Current version.
- _.VERSION = '1.1.5';
+ _.VERSION = '1.1.6';
// Collection Functions
// --------------------
@@ -168,7 +168,6 @@
// Delegates to **ECMAScript 5**'s native `every` if available.
// Aliased as `all`.
_.every = _.all = function(obj, iterator, context) {
- iterator = iterator || _.identity;
var result = true;
if (obj == null) return result;
if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
@@ -182,7 +181,7 @@
// Delegates to **ECMAScript 5**'s native `some` if available.
// Aliased as `any`.
var any = _.some = _.any = function(obj, iterator, context) {
- iterator = iterator || _.identity;
+ iterator || (iterator = _.identity);
var result = false;
if (obj == null) return result;
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
@@ -208,7 +207,7 @@
_.invoke = function(obj, method) {
var args = slice.call(arguments, 2);
return _.map(obj, function(value) {
- return (method ? value[method] : value).apply(value, args);
+ return (method.call ? method || value : value[method]).apply(value, args);
});
};
@@ -255,7 +254,7 @@
// Use a comparator function to figure out at what index an object should
// be inserted so as to maintain order. Uses binary search.
_.sortedIndex = function(array, obj, iterator) {
- iterator = iterator || _.identity;
+ iterator || (iterator = _.identity);
var low = 0, high = array.length;
while (low < high) {
var mid = (low + high) >> 1;
@@ -408,8 +407,9 @@
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally). Binding with arguments is also known as `curry`.
// Delegates to **ECMAScript 5**'s native `Function.bind` if available.
+ // We check for `func.bind` first, to fail fast when `func` is undefined.
_.bind = function(func, obj) {
- if (nativeBind && func.bind === nativeBind) return func.bind.apply(func, slice.call(arguments, 1));
+ if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
var args = slice.call(arguments, 2);
return function() {
return func.apply(obj, args.concat(slice.call(arguments)));
@@ -428,7 +428,7 @@
// Memoize an expensive function by storing its results.
_.memoize = function(func, hasher) {
var memo = {};
- hasher = hasher || _.identity;
+ hasher || (hasher = _.identity);
return function() {
var key = hasher.apply(this, arguments);
return hasOwnProperty.call(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
@@ -509,6 +509,14 @@
};
};
+ // Returns a function that will only be executed after being called N times.
+ _.after = function(times, func) {
+ return function() {
+ if (--times < 1) { return func.apply(this, arguments); }
+ };
+ };
+
+
// Object Functions
// ----------------
@@ -535,15 +543,19 @@
// Extend a given object with all the properties in passed-in object(s).
_.extend = function(obj) {
each(slice.call(arguments, 1), function(source) {
- for (var prop in source) obj[prop] = source[prop];
+ for (var prop in source) {
+ if (source[prop] !== void 0) obj[prop] = source[prop];
+ }
});
return obj;
};
// Fill in a given object with default properties.
_.defaults = function(obj) {
each(slice.call(arguments, 1), function(source) {
- for (var prop in source) if (obj[prop] == null) obj[prop] = source[prop];
+ for (var prop in source) {
+ if (obj[prop] == null) obj[prop] = source[prop];
+ }
});
return obj;
};

0 comments on commit 7b494c1

Please sign in to comment.