Skip to content

Commit

Permalink
Upgrading Backbone.js tests to Underscore 1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Mar 21, 2011
1 parent 0cdc525 commit d97d8bf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/todos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.js"></script>
<script src="../../test/vendor/underscore-1.1.5.js"></script>
<script src="../../backbone.js"></script>
<script src="../backbone-localstorage.js"></script>
<script src="todos.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,7 @@ <h2 id="changelog">Change Log</h2>

</div>

<script src="test/vendor/underscore-1.1.4.js"></script>
<script src="test/vendor/underscore-1.1.5.js"></script>
<script src="test/vendor/jquery-1.5.js"></script>
<script src="test/vendor/json2.js"></script>
<script src="backbone.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/test-zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script type="text/javascript" src="vendor/zepto-0.4.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.4.js"></script>
<script type="text/javascript" src="vendor/underscore-1.1.5.js"></script>
<script type="text/javascript" src="../backbone.js"></script>

<script type="text/javascript" src="events.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.js"></script>
<script type="text/javascript" src="vendor/underscore-1.1.5.js"></script>
<script type="text/javascript" src="../backbone.js"></script>

<script type="text/javascript" src="events.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Underscore.js 1.1.4
// Underscore.js 1.1.5
// (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
Expand All @@ -21,7 +21,7 @@
var breaker = {};

// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;

// Create quick reference variables for speed access to core prototypes.
var slice = ArrayProto.slice,
Expand All @@ -42,7 +42,8 @@
nativeIndexOf = ArrayProto.indexOf,
nativeLastIndexOf = ArrayProto.lastIndexOf,
nativeIsArray = Array.isArray,
nativeKeys = Object.keys;
nativeKeys = Object.keys,
nativeBind = FuncProto.bind;

// Create a safe reference to the Underscore object for use below.
var _ = function(obj) { return new wrapper(obj); };
Expand All @@ -58,7 +59,7 @@
}

// Current version.
_.VERSION = '1.1.4';
_.VERSION = '1.1.5';

// Collection Functions
// --------------------
Expand Down Expand Up @@ -406,10 +407,12 @@

// 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.
_.bind = function(func, obj) {
if (nativeBind && func.bind === nativeBind) return func.bind.apply(func, slice.call(arguments, 1));
var args = slice.call(arguments, 2);
return function() {
return func.apply(obj || {}, args.concat(slice.call(arguments)));
return func.apply(obj, args.concat(slice.call(arguments)));
};
};

Expand Down Expand Up @@ -472,6 +475,17 @@
return limit(func, wait, true);
};

// Returns a function that will be executed at most one time, no matter how
// often you call it. Useful for lazy initialization.
_.once = function(func) {
var ran = false, memo;
return function() {
if (ran) return memo;
ran = true;
return memo = func.apply(this, arguments);
};
};

// Returns the first function passed as an argument to the second,
// allowing you to adjust arguments, run code before and after, and
// conditionally execute the original function.
Expand Down Expand Up @@ -501,6 +515,7 @@
// Retrieve the names of an object's properties.
// Delegates to **ECMAScript 5**'s native `Object.keys`
_.keys = nativeKeys || function(obj) {
if (obj !== Object(obj)) throw new TypeError('Invalid object');
var keys = [];
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;
return keys;
Expand Down

0 comments on commit d97d8bf

Please sign in to comment.