pick-truthy-values
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

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 ]
 

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i pick-truthy-values

    Weekly Downloads

    3

    Version

    1.0.7

    License

    MIT

    Unpacked Size

    14.5 kB

    Total Files

    17

    Last publish

    Collaborators

    • tameemsafi