mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
comment edits
This commit is contained in:
16
index.html
16
index.html
@@ -160,7 +160,7 @@
|
||||
function. The <b>iterator</b> is bound to the <b>context</b> object, if one is
|
||||
passed. If <b>list</b> is a Javascript object, a pair with <b>key</b>
|
||||
and <b>value</b> properties will be yielded. If the list has an <b>each</b>
|
||||
method of its own defined, it will be used. Delegates to the native
|
||||
method of its own, it will be used instead. Delegates to the native
|
||||
<b>forEach</b> function if it exists.
|
||||
</p>
|
||||
<pre>
|
||||
@@ -196,8 +196,8 @@ var sum = _.inject([1, 2, 3], 0, function(memo, num){ return memo + num });
|
||||
<br />
|
||||
Looks through each value in the <b>list</b>, returning the first one that
|
||||
passes a truth test (<b>iterator</b>). The function returns as
|
||||
soon as it finds the true element, and doesn't continue to traverse
|
||||
the list.
|
||||
soon as it finds the first acceptable element, and doesn't continue to
|
||||
traverse the list.
|
||||
</p>
|
||||
<pre>
|
||||
var even = _.detect([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
|
||||
@@ -257,7 +257,7 @@ _.any([null, 0, 'yes', false]);
|
||||
<b class="method_name">include</b><code>_.include(list, value)</code>
|
||||
<br />
|
||||
Returns <i>true</i> if the <b>value</b> is present in the <b>list</b>, using
|
||||
<i>==</i> to test equality. Uses <b>indexOf</b> internally, if <b>list</b>
|
||||
<i>===</i> to test equality. Uses <b>indexOf</b> internally, if <b>list</b>
|
||||
is an Array.
|
||||
</p>
|
||||
<pre>
|
||||
@@ -408,7 +408,7 @@ _.flatten([1, [2], [3, [[[4]]]]]);
|
||||
<b class="method_name">without</b><code>_.without(array, [*values])</code>
|
||||
<br />
|
||||
Returns a copy of the <b>array</b> with all instances of the <b>values</b>
|
||||
removed. <i>==</i> is used for the equality test.
|
||||
removed. <i>===</i> is used for the equality test.
|
||||
</p>
|
||||
<pre>
|
||||
_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
@@ -418,7 +418,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
<p id="uniq">
|
||||
<b class="method_name">uniq</b><code>_.uniq(array, [isSorted])</code>
|
||||
<br />
|
||||
Produces a duplicate-free version of the <b>array</b>, using <i>==</i> to test
|
||||
Produces a duplicate-free version of the <b>array</b>, using <i>===</i> to test
|
||||
object equality. If you know in advance that the <b>array</b> is sorted,
|
||||
passing <i>true</i> for <b>isSorted</b> will run a much faster algorithm.
|
||||
</p>
|
||||
@@ -679,6 +679,10 @@ _.template(list, {people : ['moe', 'curly', 'larry']});
|
||||
=> "<li>moe</li><li>curly</li><li>larry</li>"
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<i><b>Underscore</b> is a <a href="http://documentcloud.org/">DocumentCloud</a> production.</i>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@ window._ = {
|
||||
VERSION : '0.1.0',
|
||||
|
||||
// The cornerstone, an each implementation.
|
||||
// Handles objects implementing forEach, _each, arrays, and raw objects.
|
||||
// Handles objects implementing forEach, each, arrays, and raw objects.
|
||||
each : function(obj, iterator, context) {
|
||||
var index = 0;
|
||||
try {
|
||||
@@ -47,7 +47,7 @@ window._ = {
|
||||
},
|
||||
|
||||
// Inject builds up a single result from a list of values. Also known as
|
||||
// reduce, and foldl.
|
||||
// reduce, or foldl.
|
||||
inject : function(obj, memo, iterator, context) {
|
||||
_.each(obj, function(value, index) {
|
||||
memo = iterator.call(context, memo, value, index);
|
||||
@@ -113,12 +113,12 @@ window._ = {
|
||||
},
|
||||
|
||||
// Determine if a given value is included in the array or object,
|
||||
// based on '=='.
|
||||
// based on '==='.
|
||||
include : function(obj, target) {
|
||||
if (_.isArray(obj)) return _.indexOf(obj, target) != -1;
|
||||
var found = false;
|
||||
_.each(obj, function(pair) {
|
||||
if (pair.value == target) {
|
||||
if (pair.value === target) {
|
||||
found = true;
|
||||
throw '__break__';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user