Navigation Menu

Skip to content

Commit

Permalink
Docs: Add links to iteratee
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian-R committed Nov 24, 2016
1 parent 314eb03 commit 089b930
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions index.html
Expand Up @@ -481,8 +481,9 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<b class="header">each</b><code>_.each(list, iteratee, [context])</code>
<span class="alias">Alias: <b>forEach</b></span>
<br />
Iterates over a <b>list</b> of elements, yielding each in turn to an <b>iteratee</b>
function. The <b>iteratee</b> is bound to the <b>context</b> object, if one is
Iterates over a <b>list</b> of elements, yielding each in turn to an
<b>iteratee</b> function.
The <b>iteratee</b> is bound to the <b>context</b> object, if one is
passed. Each invocation of <b>iteratee</b> is called with three arguments:
<tt>(element, index, list)</tt>. If <b>list</b> is a JavaScript object, <b>iteratee</b>'s
arguments will be <tt>(value, key, list)</tt>. Returns the <b>list</b> for chaining.
Expand All @@ -509,10 +510,10 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<span class="alias">Alias: <b>collect</b></span>
<br />
Produces a new array of values by mapping each value in <b>list</b>
through a transformation function (<b>iteratee</b>). The iteratee
is passed three arguments: the <tt>value</tt>, then the <tt>index</tt>
(or <tt>key</tt>) of the iteration, and finally a reference to the entire
<tt>list</tt>.
through a transformation function (<a href="#iteratee"><b>iteratee</b></a>).
The iteratee is passed three arguments: the <tt>value</tt>,
then the <tt>index</tt> (or <tt>key</tt>) of the iteration,
and finally a reference to the entire <tt>list</tt>.
</p>
<pre>
_.map([1, 2, 3], function(num){ return num * 3; });
Expand Down Expand Up @@ -564,6 +565,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
passes the test. The function returns as
soon as it finds an acceptable element, and doesn't traverse the
entire list.
<b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
to facilitate shorthand syntaxes.
</p>
<pre>
var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
Expand All @@ -576,6 +579,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<br />
Looks through each value in the <b>list</b>, returning an array of all
the values that pass a truth test (<b>predicate</b>).
<b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
to facilitate shorthand syntaxes.
</p>
<pre>
var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
Expand Down Expand Up @@ -617,6 +622,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<br />
Returns the values in <b>list</b> without the elements that the truth
test (<b>predicate</b>) passes. The opposite of <b>filter</b>.
<b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
to facilitate shorthand syntaxes.
</p>
<pre>
var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
Expand All @@ -630,6 +637,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
Returns <i>true</i> if all of the values in the <b>list</b> pass the
<b>predicate</b> truth test. Short-circuits and stops traversing the list
if a false element is found.
<b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
to facilitate shorthand syntaxes.
</p>
<pre>
_.every([2, 4, 5], function(num) { return num % 2 == 0; });
Expand All @@ -643,6 +652,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
Returns <i>true</i> if any of the values in the <b>list</b> pass the
<b>predicate</b> truth test. Short-circuits and stops traversing the list
if a true element is found.
<b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
to facilitate shorthand syntaxes.
</p>
<pre>
_.some([null, 0, 'yes', false]);
Expand Down Expand Up @@ -689,7 +700,7 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<p id="max">
<b class="header">max</b><code>_.max(list, [iteratee], [context])</code>
<br />
Returns the maximum value in <b>list</b>. If an <b>iteratee</b>
Returns the maximum value in <b>list</b>. If an <a href="#iteratee"><b>iteratee</b></a>
function is provided, it will be used on each value to generate the
criterion by which the value is ranked. <i>-Infinity</i> is returned
if <b>list</b> is empty, so an <a href="#isEmpty">isEmpty</a> guard
Expand All @@ -704,7 +715,7 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<p id="min">
<b class="header">min</b><code>_.min(list, [iteratee], [context])</code>
<br />
Returns the minimum value in <b>list</b>. If an <b>iteratee</b>
Returns the minimum value in <b>list</b>. If an <a href="#iteratee"><b>iteratee</b></a>
function is provided, it will be used on each value to generate the
criterion by which the value is ranked. <i>Infinity</i> is returned
if <b>list</b> is empty, so an <a href="#isEmpty">isEmpty</a> guard
Expand All @@ -720,7 +731,7 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<b class="header">sortBy</b><code>_.sortBy(list, iteratee, [context])</code>
<br />
Returns a (stably) sorted copy of <b>list</b>, ranked in ascending
order by the results of running each value through <b>iteratee</b>.
order by the results of running each value through <a href="#iteratee"><b>iteratee</b></a>.
iteratee may also be the string name of the property to sort by (eg.
<tt>length</tt>).
</p>
Expand Down Expand Up @@ -751,8 +762,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<p id="indexBy">
<b class="header">indexBy</b><code>_.indexBy(list, iteratee, [context])</code>
<br />
Given a <b>list</b>, and an <b>iteratee</b> function that returns a
key for each element in the list (or a property name),
Given a <b>list</b>, and an <a href="#iteratee"><b>iteratee</b></a> function
that returns a key for each element in the list (or a property name),
returns an object with an index of each item.
Just like <a href="#groupBy">groupBy</a>, but for when you know your
keys are unique.
Expand Down Expand Up @@ -834,6 +845,8 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<br />
Split <b>array</b> into two arrays: one whose elements all satisfy
<b>predicate</b> and one whose elements all do not satisfy <b>predicate</b>.
<b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
to facilitate shorthand syntaxes.
</p>
<pre>
_.partition([0, 1, 2, 3, 4, 5], isOdd);
Expand Down Expand Up @@ -975,7 +988,7 @@ <h2 id="arrays">Array Functions</h2>
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.
If you want to compute unique items based on a transformation, pass an
<b>iteratee</b> function.
<a href="#iteratee"><b>iteratee</b></a> function.
</p>
<pre>
_.uniq([1, 2, 1, 4, 1, 3]);
Expand Down Expand Up @@ -1059,8 +1072,8 @@ <h2 id="arrays">Array Functions</h2>
<br />
Uses a binary search to determine the index at which the <b>value</b>
<i>should</i> be inserted into the <b>list</b> in order to maintain the <b>list</b>'s
sorted order. If an <b>iteratee</b> function is provided, it will be used to compute
the sort ranking of each value, including the <b>value</b> you pass.
sorted order. If an <a href="#iteratee"><b>iteratee</b></a> function is provided,
it will be used to compute the sort ranking of each value, including the <b>value</b> you pass.
The iteratee may also be the string name of the property to sort by (eg. <tt>length</tt>).
</p>
<pre>
Expand Down Expand Up @@ -1349,7 +1362,7 @@ <h2 id="functions">Function (uh, ahem) Functions</h2>
<p id="negate">
<b class="header">negate</b><code>_.negate(predicate)</code>
<br />
Returns a new negated version of the <b>predicate</b> function.
Returns a new negated version of the <a href="#iteratee"><b>predicate</b></a> function.
</p>
<pre>
var isFalsy = _.negate(Boolean);
Expand Down Expand Up @@ -1474,6 +1487,8 @@ <h2 id="objects">Object Functions</h2>
Similar to <a href="#findIndex"><tt>_.findIndex</tt></a> but for keys in objects.
Returns the <i>key</i> where the <b>predicate</b> truth test
passes or <i>undefined</i>.
<b>predicate</b> is transformed through <a href="#iteratee"><b>iteratee</b></a>
to facilitate shorthand syntaxes.
</p>

<p id="extend">
Expand Down Expand Up @@ -1890,8 +1905,8 @@ <h2 id="utility">Utility Functions</h2>
<b class="header">times</b><code>_.times(n, iteratee, [context])</code>
<br />
Invokes the given iteratee function <b>n</b> times. Each invocation of
<b>iteratee</b> is called with an <tt>index</tt> argument. Produces an
array of the returned values.
<a href="#iteratee"><b>iteratee</b></a> is called with an <tt>index</tt> argument.
Produces an array of the returned values.
<br />
<i>Note: this example uses the <a href="#oop">object-oriented syntax</a></i>.
</p>
Expand Down

0 comments on commit 089b930

Please sign in to comment.