1.0.7 • Published 5 years ago

pick-truthy-values v1.0.7

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

pickTruthyValues

CircleCI

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

Examples

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 ]