Code preview
1 import map from 'map.js';
2 import basePickBy from './.internal/basePickBy.js';
3 import getAllKeysIn from './.internal/getAllKeysIn.js';
4
5 /**
6 * Creates an object composed of the `object` properties `predicate` returns
7 * truthy for. The predicate is invoked with two arguments: (value, key).
8 */
9 function pickBy(object, predicate) {
10 if (object == null) {
11 return {};
12 }
13 const props = map(getAllKeysIn(object), prop => [prop]);
14 return basePickBy(object, props, (value, path) => predicate(value, path[0]));
15 }
16
17 export default pickBy;
Terminal preview
~/project (branch*) $ npm run test
$ jest
PASS packages/themer/lib/prepare.spec.js
PASS packages/themer-wallpaper-triangles/lib/index.spec.js
PASS packages/themer-vscode/lib/index.spec.js
PASS packages/themer-utils/lib/index.spec.js
PASS packages/themer-wallpaper-octagon/lib/index.spec.js
PASS packages/themer-atom-syntax/lib/index.spec.js
PASS packages/themer-chrome/lib/index.spec.js
...
Test Suites: 42 passed, 42 total
Tests: 145 passed, 145 total
Snapshots: 102 passed, 102 total
Time: 5.626s
Ran all test suites.
~/project (branch*) $