Merging in #194, adding an iterator to _.uniq

This commit is contained in:
Jeremy Ashkenas
2011-08-03 11:32:31 -04:00
3 changed files with 20 additions and 4 deletions

View File

@@ -592,12 +592,14 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
</pre>
<p id="uniq">
<b class="header">uniq</b><code>_.uniq(array, [isSorted])</code>
<b class="header">uniq</b><code>_.uniq(array, [isSorted], [iterator])</code>
<span class="alias">Alias: <b>unique</b></span>
<br />
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.
If you want to compute unique items based on a transformation, pass an
<b>iterator</b> function.
</p>
<pre>
_.uniq([1, 2, 1, 3, 1, 4]);