Skip to content

Commit

Permalink
Merge pull request jashkenas#2655 from wotkuni/docs-compact-array
Browse files Browse the repository at this point in the history
Docs: move _.compact to Collections section
  • Loading branch information
captbaritone authored Feb 15, 2017
2 parents 6611850 + 1674e0f commit 731d8d4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
49 changes: 25 additions & 24 deletions docs/underscore.html
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,27 @@ <h2 id="collection-functions">Collection Functions</h2>
};</pre></div></div>

</li>


<li id="section-49">
<div class="annotation">

<div class="pilwrap ">
<a class="pilcrow" href="#section-55">&#182;</a>
</div>
<p>Trim out all falsy values from an object.</p>

</div>

<div class="content"><div class='highlight'><pre> _.compact = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> </span>{
<span class="hljs-keyword">return</span> _.filter(obj, _.identity);
};</pre></div></div>

</li>



<li id="section-49">
<li id="section-50">
<div class="annotation">

<div class="pilwrap ">
Expand All @@ -1057,7 +1075,7 @@ <h2 id="array-functions">Array Functions</h2>
</li>


<li id="section-50">
<li id="section-51">
<div class="annotation">

<div class="pilwrap ">
Expand All @@ -1069,7 +1087,7 @@ <h2 id="array-functions">Array Functions</h2>
</li>


<li id="section-51">
<li id="section-52">
<div class="annotation">

<div class="pilwrap ">
Expand All @@ -1090,7 +1108,7 @@ <h2 id="array-functions">Array Functions</h2>
</li>


<li id="section-52">
<li id="section-53">
<div class="annotation">

<div class="pilwrap ">
Expand All @@ -1109,7 +1127,7 @@ <h2 id="array-functions">Array Functions</h2>
</li>


<li id="section-53">
<li id="section-54">
<div class="annotation">

<div class="pilwrap ">
Expand All @@ -1129,7 +1147,7 @@ <h2 id="array-functions">Array Functions</h2>
</li>


<li id="section-54">
<li id="section-55">
<div class="annotation">

<div class="pilwrap ">
Expand All @@ -1145,24 +1163,7 @@ <h2 id="array-functions">Array Functions</h2>
<span class="hljs-keyword">return</span> slice.call(array, n == <span class="hljs-literal">null</span> || guard ? <span class="hljs-number">1</span> : n);
};</pre></div></div>

</li>


<li id="section-55">
<div class="annotation">

<div class="pilwrap ">
<a class="pilcrow" href="#section-55">&#182;</a>
</div>
<p>Trim out all falsy values from an array.</p>

</div>

<div class="content"><div class='highlight'><pre> _.compact = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array)</span> </span>{
<span class="hljs-keyword">return</span> _.filter(array, _.identity);
};</pre></div></div>

</li>
</li>


<li id="section-56">
Expand Down
28 changes: 14 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
<li data-name="toArray">- <a href="#toArray">toArray</a></li>
<li data-name="size">- <a href="#size">size</a></li>
<li data-name="partition">- <a href="#partition">partition</a></li>
<li data-name="compact">- <a href="#compact">compact</a></li>
</ul>
</div>

Expand All @@ -239,8 +240,7 @@
<li data-name="first" data-aliases="head take">- <a href="#first">first</a></li>
<li data-name="initial">- <a href="#initial">initial</a></li>
<li data-name="last">- <a href="#last">last</a></li>
<li data-name="rest" data-aliases="tail drop">- <a href="#rest">rest</a></li>
<li data-name="compact">- <a href="#compact">compact</a></li>
<li data-name="rest" data-aliases="tail drop">- <a href="#rest">rest</a></li>
<li data-name="flatten">- <a href="#flatten">flatten</a></li>
<li data-name="without">- <a href="#without">without</a></li>
<li data-name="union">- <a href="#union">union</a></li>
Expand Down Expand Up @@ -851,6 +851,18 @@ <h2 id="collections">Collection Functions (Arrays or Objects)</h2>
<pre>
_.partition([0, 1, 2, 3, 4, 5], isOdd);
=&gt; [[1, 3, 5], [0, 2, 4]]
</pre>

<p id="compact">
<b class="header">compact</b><code>_.compact(list)</code>
<br />
Returns a copy of the <b>list</b> with all falsy values removed.
In JavaScript, <i>false</i>, <i>null</i>, <i>0</i>, <i>""</i>,
<i>undefined</i> and <i>NaN</i> are all falsy.
</p>
<pre>
_.compact([0, 1, false, 2, '', 3]);
=&gt; [1, 2, 3]
</pre>

<h2 id="arrays">Array Functions</h2>
Expand Down Expand Up @@ -907,18 +919,6 @@ <h2 id="arrays">Array Functions</h2>
<pre>
_.rest([5, 4, 3, 2, 1]);
=&gt; [4, 3, 2, 1]
</pre>

<p id="compact">
<b class="header">compact</b><code>_.compact(array)</code>
<br />
Returns a copy of the <b>array</b> with all falsy values removed.
In JavaScript, <i>false</i>, <i>null</i>, <i>0</i>, <i>""</i>,
<i>undefined</i> and <i>NaN</i> are all falsy.
</p>
<pre>
_.compact([0, 1, false, 2, '', 3]);
=&gt; [1, 2, 3]
</pre>

<p id="flatten">
Expand Down

0 comments on commit 731d8d4

Please sign in to comment.