Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
590 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var baseEach = require('./_baseEach');
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 4 | * The base implementation of `_.filter` without support for iteratee shorthands.
|
---|
| 5 | *
|
---|
| 6 | * @private
|
---|
| 7 | * @param {Array|Object} collection The collection to iterate over.
|
---|
| 8 | * @param {Function} predicate The function invoked per iteration.
|
---|
| 9 | * @returns {Array} Returns the new filtered array.
|
---|
| 10 | */
|
---|
| 11 | function baseFilter(collection, predicate) {
|
---|
| 12 | var result = [];
|
---|
| 13 | baseEach(collection, function(value, index, collection) {
|
---|
| 14 | if (predicate(value, index, collection)) {
|
---|
| 15 | result.push(value);
|
---|
| 16 | }
|
---|
| 17 | });
|
---|
| 18 | return result;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | module.exports = baseFilter;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.