main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1011 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import baseIteratee from './_baseIteratee.js';
|
---|
| 2 | import baseUniq from './_baseUniq.js';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * This method is like `_.uniq` except that it accepts `iteratee` which is
|
---|
| 6 | * invoked for each element in `array` to generate the criterion by which
|
---|
| 7 | * uniqueness is computed. The order of result values is determined by the
|
---|
| 8 | * order they occur in the array. The iteratee is invoked with one argument:
|
---|
| 9 | * (value).
|
---|
| 10 | *
|
---|
| 11 | * @static
|
---|
| 12 | * @memberOf _
|
---|
| 13 | * @since 4.0.0
|
---|
| 14 | * @category Array
|
---|
| 15 | * @param {Array} array The array to inspect.
|
---|
| 16 | * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
---|
| 17 | * @returns {Array} Returns the new duplicate free array.
|
---|
| 18 | * @example
|
---|
| 19 | *
|
---|
| 20 | * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
|
---|
| 21 | * // => [2.1, 1.2]
|
---|
| 22 | *
|
---|
| 23 | * // The `_.property` iteratee shorthand.
|
---|
| 24 | * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
|
---|
| 25 | * // => [{ 'x': 1 }, { 'x': 2 }]
|
---|
| 26 | */
|
---|
| 27 | function uniqBy(array, iteratee) {
|
---|
| 28 | return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | export default uniqBy;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.