Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
632 bytes
|
Line | |
---|
1 | /**
|
---|
2 | * A specialized version of `_.filter` for arrays without support for
|
---|
3 | * iteratee shorthands.
|
---|
4 | *
|
---|
5 | * @private
|
---|
6 | * @param {Array} [array] The array to iterate over.
|
---|
7 | * @param {Function} predicate The function invoked per iteration.
|
---|
8 | * @returns {Array} Returns the new filtered array.
|
---|
9 | */
|
---|
10 | function arrayFilter(array, predicate) {
|
---|
11 | var index = -1,
|
---|
12 | length = array == null ? 0 : array.length,
|
---|
13 | resIndex = 0,
|
---|
14 | result = [];
|
---|
15 |
|
---|
16 | while (++index < length) {
|
---|
17 | var value = array[index];
|
---|
18 | if (predicate(value, index, array)) {
|
---|
19 | result[resIndex++] = value;
|
---|
20 | }
|
---|
21 | }
|
---|
22 | return result;
|
---|
23 | }
|
---|
24 |
|
---|
25 | module.exports = arrayFilter;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.