main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
696 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import baseIteratee from './_baseIteratee.js';
|
---|
| 2 | import baseSortedUniq from './_baseSortedUniq.js';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * This method is like `_.uniqBy` except that it's designed and optimized
|
---|
| 6 | * for sorted arrays.
|
---|
| 7 | *
|
---|
| 8 | * @static
|
---|
| 9 | * @memberOf _
|
---|
| 10 | * @since 4.0.0
|
---|
| 11 | * @category Array
|
---|
| 12 | * @param {Array} array The array to inspect.
|
---|
| 13 | * @param {Function} [iteratee] The iteratee invoked per element.
|
---|
| 14 | * @returns {Array} Returns the new duplicate free array.
|
---|
| 15 | * @example
|
---|
| 16 | *
|
---|
| 17 | * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
|
---|
| 18 | * // => [1.1, 2.3]
|
---|
| 19 | */
|
---|
| 20 | function sortedUniqBy(array, iteratee) {
|
---|
| 21 | return (array && array.length)
|
---|
| 22 | ? baseSortedUniq(array, baseIteratee(iteratee, 2))
|
---|
| 23 | : [];
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | export default sortedUniqBy;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.