Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
791 bytes
|
Line | |
---|
1 | var baseGet = require('./_baseGet'),
|
---|
2 | baseSet = require('./_baseSet'),
|
---|
3 | castPath = require('./_castPath');
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * The base implementation of `_.pickBy` without support for iteratee shorthands.
|
---|
7 | *
|
---|
8 | * @private
|
---|
9 | * @param {Object} object The source object.
|
---|
10 | * @param {string[]} paths The property paths to pick.
|
---|
11 | * @param {Function} predicate The function invoked per property.
|
---|
12 | * @returns {Object} Returns the new object.
|
---|
13 | */
|
---|
14 | function basePickBy(object, paths, predicate) {
|
---|
15 | var index = -1,
|
---|
16 | length = paths.length,
|
---|
17 | result = {};
|
---|
18 |
|
---|
19 | while (++index < length) {
|
---|
20 | var path = paths[index],
|
---|
21 | value = baseGet(object, path);
|
---|
22 |
|
---|
23 | if (predicate(value, path)) {
|
---|
24 | baseSet(result, castPath(path, object), value);
|
---|
25 | }
|
---|
26 | }
|
---|
27 | return result;
|
---|
28 | }
|
---|
29 |
|
---|
30 | module.exports = basePickBy;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.