mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Rework of #68, to use a flag to indexOf, instead of a separate function.
This commit is contained in:
20
index.html
20
index.html
@@ -142,7 +142,6 @@
|
||||
<a href="#invoke">invoke</a>, <a href="#pluck">pluck</a>,
|
||||
<a href="#max">max</a>, <a href="#min">min</a>,
|
||||
<a href="#sortBy">sortBy</a>, <a href="#sortedIndex">sortedIndex</a>,
|
||||
<a href="#sortedIndexOf">sortedIndexOf</a>,
|
||||
<a href="#toArray">toArray</a>, <a href="#size">size</a></span>
|
||||
</p>
|
||||
|
||||
@@ -453,19 +452,6 @@ _.sortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); });
|
||||
<pre>
|
||||
_.sortedIndex([10, 20, 30, 40, 50], 35);
|
||||
=> 3
|
||||
</pre>
|
||||
|
||||
<p id="sortedIndexOf">
|
||||
<b class="header">sortedIndexOf</b><code>_.sortedIndexOf(list, value)</code>
|
||||
<br />
|
||||
Not to be confused with <tt>_.sortedIndex</tt>, this method works like
|
||||
the native <tt>indexOf</tt>, but uses binary search to efficiently
|
||||
find the value in large, already-sorted arrays. Returns <tt>-1</tt>
|
||||
if the value is not present.
|
||||
</p>
|
||||
<pre>
|
||||
_.sortedIndex([10, 20, 30, 40, 50], 30);
|
||||
=> 2
|
||||
</pre>
|
||||
|
||||
<p id="toArray">
|
||||
@@ -599,11 +585,13 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
|
||||
</pre>
|
||||
|
||||
<p id="indexOf">
|
||||
<b class="header">indexOf</b><code>_.indexOf(array, value)</code>
|
||||
<b class="header">indexOf</b><code>_.indexOf(array, value, [isSorted])</code>
|
||||
<br />
|
||||
Returns the index at which <b>value</b> can be found in the <b>array</b>,
|
||||
or <i>-1</i> if value is not present in the <b>array</b>. Uses the native
|
||||
<b>indexOf</b> function unless it's missing.
|
||||
<b>indexOf</b> function unless it's missing. If you're working with a
|
||||
large array, and you know that the array is already sorted, pass <tt>true</tt>
|
||||
for <b>isSorted</b> to use a faster binary search.
|
||||
</p>
|
||||
<pre>
|
||||
_.indexOf([1, 2, 3], 2);
|
||||
|
||||
Reference in New Issue
Block a user