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:
956 bytes
|
Line | |
---|
1 | import baseUniq from './_baseUniq.js';
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * This method is like `_.uniq` except that it accepts `comparator` which
|
---|
5 | * is invoked to compare elements of `array`. The order of result values is
|
---|
6 | * determined by the order they occur in the array.The comparator is invoked
|
---|
7 | * with two arguments: (arrVal, othVal).
|
---|
8 | *
|
---|
9 | * @static
|
---|
10 | * @memberOf _
|
---|
11 | * @since 4.0.0
|
---|
12 | * @category Array
|
---|
13 | * @param {Array} array The array to inspect.
|
---|
14 | * @param {Function} [comparator] The comparator invoked per element.
|
---|
15 | * @returns {Array} Returns the new duplicate free array.
|
---|
16 | * @example
|
---|
17 | *
|
---|
18 | * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
|
---|
19 | *
|
---|
20 | * _.uniqWith(objects, _.isEqual);
|
---|
21 | * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
|
---|
22 | */
|
---|
23 | function uniqWith(array, comparator) {
|
---|
24 | comparator = typeof comparator == 'function' ? comparator : undefined;
|
---|
25 | return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
|
---|
26 | }
|
---|
27 |
|
---|
28 | export default uniqWith;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.