y-strip

remove falsy value from object

Usage no npm install needed!

<script type="module">
  import yStrip from 'https://cdn.skypack.dev/y-strip';
</script>

README

y-strip

Intro

Remove falsy value from object.

Usage

import SO from 'y-strip'

const so = new SO()
const obj = {
  a: 1,
  b: '',
  c: false,
  d: null,
  e: undefined,
  f: 0
}
const result = so.strip(obj)
console.log(result) // { a: 1 }

const sso = new SO(true)
const resultS = sso.stript(obj)
console.log(resultS) // { a: 1, b: '', d: null, e: undefined, f: 0}

Option

const so = new SO(strict)
  • [strict=false] whether only strip value that === false.