12 lines
269 B
JavaScript
12 lines
269 B
JavaScript
|
'use strict'
|
||
|
module.exports = function objFilter (original, filter) {
|
||
|
const obj = {}
|
||
|
filter = filter || ((k, v) => true)
|
||
|
Object.keys(original || {}).forEach((key) => {
|
||
|
if (filter(key, original[key])) {
|
||
|
obj[key] = original[key]
|
||
|
}
|
||
|
})
|
||
|
return obj
|
||
|
}
|