clean

v1.0.0arrow_drop_down
v1.0.0
v0.0.1
STATUS
Passing
DOWNLOADS
3
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
subject
Cleans all object's properties that contains a falsy value and returns a new object without them.
2 contributors
Like
Use clean in your project ?
Copied
npm i @bit/bit.utils.object.clean
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
revert changes
reload
toggle layout
maximize
new cleaned object clean({ foo: null, bar: 'foo' }) // => { bar: 'foo' }
modifieddraft
chevron_left
chevron_right
clean (
obj:object
) : object

Cleans all object’s properties that contains a falsy value and returns a new object without them.

Example
new cleaned object
 clean({ foo: null, bar: 'foo' }) // => { bar: 'foo' }
Argument
obj: object

object to clean

Returns
object

Test Summary

#clean() should clean property foo as its value is falsy

Pass

#clean() should return an empty object as all properties are falsy

Pass

#clean() should throw a type error in case a non-object value was passed

Pass