obj-filter.js 269 B

1234567891011
  1. 'use strict'
  2. module.exports = function objFilter (original, filter) {
  3. const obj = {}
  4. filter = filter || ((k, v) => true)
  5. Object.keys(original || {}).forEach((key) => {
  6. if (filter(key, original[key])) {
  7. obj[key] = original[key]
  8. }
  9. })
  10. return obj
  11. }