Skip to content

shake

Remove unwanted values from an object

120 bytes

Usage

A bit like _.sift but for objects. By default, it will return a new object with all the undefined attributes removed. You can pass a second function argument to remove any attributes by a custom condition.

import * as _ from 'radashi'
const ra = {
mode: 'god',
greek: false,
limit: undefined,
}
_.shake(ra) // => { mode, greek }
_.shake(ra, a => !a) // => { mode }