1.0.0 • Published 4 years ago

deep-pick-by v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

deep-pick-by

Recursively pick an object or an array by given criteria.

Installation

npm install deep-pick-by --save

Usage

const deepPickBy = require('deep-pick-by');

const collection = {
  a: 0,
  b: 0,
  c: {
    a: 0,
    b: 0,
    c: {
      a: 0,
      b: 0,
    },
  },
};

deepPickBy(collection, (val, key) => key === 'a');
//=> { a: 0, c: { a: 0, c: { a: 0 } } }