Remove any prop (eg. `undefined`) from an object
npm install remove-anything```
npm i remove-anything
Removes props (eg. undefined) from an object
An optimised way to remove any prop value (eg. undefined, empty objects, ...) from an object. A small and simple integration.
`js
import { removeProp } from 'remove-anything'
const payload = { a: 1, b: undefined }
const noUndefined = removeProp(payload, undefined)
noUndefined // { a: 1 }
const payload = { a: 1, b: undefined }
const no1 = removeProp(payload, 1)
no1 // { b: undefined }
`
You can keep on passing parameters to remove additional props
`js
const payload = { a: 1, b: undefined }
removeProp(payload, 1, undefined)
// returns
// {}
`
`js
const payload = { a: 1, b: undefined, c: {}, d: [] }
removeProps(payload, {}, [])
// returns
// { a: 1, b: undefined }
`
Use removePropInPlace to mutate the original object instead of creating a new one:
`js
const payload = { a: 1, b: undefined, c: {} }
removePropInPlace(payload, undefined, {})
// payload is now mutated to: { a: 1 }
``
- is-what 🙉
- is-where 🙈
- merge-anything 🥡
- check-anything 👁
- remove-anything ✂️
- getorset-anything 🐊
- map-anything 🗺
- filter-anything ⚔️
- copy-anything 🎭
- case-anything 🐫
- flatten-anything 🏏
- nestify-anything 🧅