Returns a new object containing all elements of the calling object for which the provided filter callback returns true

Creates a copy of an object containing all elements for which the provided filter callback returns true.
Like Array.prototype.filter() but for objects.
This project has no dependencies.
npm install @arnaudnyc/object-filter
yarn add @arnaudnyc/object-filter
``
const objectFilter = require('@arnaudnyc/object-filter');
const object = {
keep: 'yes',
discard: 'no',
};
const filteredByProperty = objectFilter(object, property => property === 'keep');
console.log('filteredByProperty:', filteredByProperty); // filteredByProperty: { keep: 'yes' }
const filteredByValue = objectFilter(object, (property, value) => value === 'yes');
console.log('filteredByValue:', filteredByValue); // filteredByValue: { keep: 'yes' }
// no mutation
console.log('object:', object); // object: { keep: 'yes', discard: 'no' }
`
npm test or yarn test`
Made with ❤️ in 🗽