foldl. Delegates to ECMAScript 5's native memo = iterator.call(context, memo, value, index, list);
});
return memo;
- }; The right-associative version of reduce, also known as foldr. Uses
-Delegates to ECMAScript 5's native reduceRight if available.
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
+ };
The right-associative version of reduce, also known as foldr.
+Delegates to ECMAScript 5's native reduceRight if available.
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
if (context) iterator = _.bind(iterator, context);
return obj.reduceRight(iterator, memo);
}
var reversed = (_.isArray(obj) ? obj.slice() : _.toArray(obj)).reverse();
return _.reduce(reversed, iterator, memo, context);
- };
Return the first value which passes a truth test.
_.detect = function(obj, iterator, context) {
+ };
Return the first value which passes a truth test. Aliased as detect.
_.find = _.detect = function(obj, iterator, context) {
var result;
each(obj, function(value, index, list) {
if (iterator.call(context, value, index, list)) {
@@ -74,7 +74,7 @@ Delegates to ECMAScript 5's native reduceRight if available.return result;
};
Return all the elements that pass a truth test.
Delegates to ECMAScript 5's native filter if available.
-Aliased as select
_.filter = _.select = function(obj, iterator, context) {
+Aliased as select.
_.filter = _.select = function(obj, iterator, context) {
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
var results = [];
each(obj, function(value, index, list) {
@@ -207,7 +207,7 @@ an index go together.
var results = new Array(length);
for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
return results;
- }; If the browser doesn't supply us with indexOf (I'm looking at you, MSIE),
+ };
If the browser doesn't supply us with indexOf (I'm looking at you, MSIE),
we need this function. Return the position of the first occurence of an
item in an array, or -1 if the item is not included in the array.
Delegates to ECMAScript 5's native indexOf if available.
_.indexOf = function(array, item) {
diff --git a/test/objects.js b/test/objects.js
index fc9c93d42..4f7ee02e0 100644
--- a/test/objects.js
+++ b/test/objects.js
@@ -12,7 +12,7 @@ $(document).ready(function() {
test("objects: functions", function() {
var expected = ["all", "any", "bind", "bindAll", "breakLoop", "clone", "compact",
- "compose", "contains", "defer", "delay", "detect", "each", "every", "extend", "filter", "first",
+ "compose", "contains", "defer", "delay", "detect", "each", "every", "extend", "filter", "find", "first",
"flatten", "foldl", "foldr", "forEach", "functions", "head", "identity", "include",
"indexOf", "inject", "intersect", "invoke", "isArguments", "isArray", "isBoolean", "isDate", "isElement", "isEmpty", "isEqual",
"isFunction", "isNaN", "isNull", "isNumber", "isRegExp", "isString", "isUndefined", "keys", "last", "lastIndexOf", "map", "max",
diff --git a/test/utility.js b/test/utility.js
index 066f8ba67..db87a4d08 100644
--- a/test/utility.js
+++ b/test/utility.js
@@ -108,8 +108,8 @@ $(document).ready(function() {
equals(quoteInStatementAndBody({foo: "bar"}), "Statement quotes and 'quotes'.");
_.templateSettings = {
- evaluate : /<%([\s\S]+?)%>/g,
- interpolate : /<%=([\s\S]+?)%>/g
+ evaluate : /<\?([\s\S]+?)\?>/g,
+ interpolate : /<\?=([\s\S]+?)\?>/g
};
var customWithSpecialChars = _.template("
for (key in people) { ?>- = people[key] ?>
} ?>
");
diff --git a/underscore.js b/underscore.js
index 72dbd1d16..9dce73ef0 100644
--- a/underscore.js
+++ b/underscore.js
@@ -103,8 +103,8 @@
return memo;
};
- // The right-associative version of reduce, also known as `foldr`. Uses
- // Delegates to **ECMAScript 5**'s native reduceRight if available.
+ // The right-associative version of reduce, also known as `foldr`.
+ // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
if (context) iterator = _.bind(iterator, context);
@@ -114,8 +114,8 @@
return _.reduce(reversed, iterator, memo, context);
};
- // Return the first value which passes a truth test.
- _.detect = function(obj, iterator, context) {
+ // Return the first value which passes a truth test. Aliased as `detect`.
+ _.find = _.detect = function(obj, iterator, context) {
var result;
each(obj, function(value, index, list) {
if (iterator.call(context, value, index, list)) {
@@ -128,7 +128,7 @@
// Return all the elements that pass a truth test.
// Delegates to **ECMAScript 5**'s native `filter` if available.
- // Aliased as `select`
+ // Aliased as `select`.
_.filter = _.select = function(obj, iterator, context) {
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
var results = [];
@@ -330,7 +330,7 @@
return results;
};
- // If the browser doesn't supply us with indexOf (I'm looking at you, MSIE),
+ // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
// we need this function. Return the position of the first occurence of an
// item in an array, or -1 if the item is not included in the array.
// Delegates to **ECMAScript 5**'s native `indexOf` if available.