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:
756 bytes
|
Line | |
---|
1 | import eq from './eq.js';
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
|
---|
5 | * support for iteratee shorthands.
|
---|
6 | *
|
---|
7 | * @private
|
---|
8 | * @param {Array} array The array to inspect.
|
---|
9 | * @param {Function} [iteratee] The iteratee invoked per element.
|
---|
10 | * @returns {Array} Returns the new duplicate free array.
|
---|
11 | */
|
---|
12 | function baseSortedUniq(array, iteratee) {
|
---|
13 | var index = -1,
|
---|
14 | length = array.length,
|
---|
15 | resIndex = 0,
|
---|
16 | result = [];
|
---|
17 |
|
---|
18 | while (++index < length) {
|
---|
19 | var value = array[index],
|
---|
20 | computed = iteratee ? iteratee(value) : value;
|
---|
21 |
|
---|
22 | if (!index || !eq(computed, seen)) {
|
---|
23 | var seen = computed;
|
---|
24 | result[resIndex++] = value === 0 ? 0 : value;
|
---|
25 | }
|
---|
26 | }
|
---|
27 | return result;
|
---|
28 | }
|
---|
29 |
|
---|
30 | export default baseSortedUniq;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.