Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tameemsafi/pick-truthy-values

Utility function to remove any falsy values from arrays/object written in typescript
https://github.com/tameemsafi/pick-truthy-values

js library npm typescript utility

Last synced: 23 days ago
JSON representation

Utility function to remove any falsy values from arrays/object written in typescript

Awesome Lists containing this project

README

        

# pickTruthyValues

[![CircleCI](https://circleci.com/gh/tameemsafi/pick-truthy-values/tree/master.svg?style=svg)](https://circleci.com/gh/tameemsafi/pick-truthy-values/tree/master)

Utility function which removes any falsy values from arrays/objects written in typescript.

## Examples

```js
import { pickTruthyValues } from 'pick-truthy-values'

pickTruthyValues({
a: null,
b: undefined,
c: '',
e: [],
})

// => {}

pickTruthyValues({
a: {
b: [
{ c: null }
]
}
})

// => {}

pickTruthyValues({
a: {
b: [
{ c: null },
{ d: 'test' }
]
}
})

// => { a: { b: [ { d: 'test' } ] } }

pickTruthyValues([ 1, 2, 3, null, 4, 5, undefined, 6, false ])

// => [ 1, 2, 3, 4, 5, 6, false ]

```