Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

pick-truthy-values

tameemsafi7MIT1.0.7TypeScript support: included

CircleCI

utility, remove empty values, pick, clean object, clean array, filter object, remove null values, remove falsy values

readme

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 ]