Skip to content
Bucklescript bindings for clean-deep: remove empty or nullable values from javascript objects
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
src
.gitignore
.travis.yml
LICENSE
README.md
bsconfig.json
package.json
yarn.lock

README.md

bs-clean-deep

NPM version Build Status

Bindings for clean-deep, a library for removing empty or nullable values from javascript objects.

Getting started

yarn add bs-clean-deep

Then add bs-clean-deep as a dependency to bsconfig.json:

"bs-dependencies": [
+  "bs-clean-deep"
]

Example

open BsCleanDeep;

let jsObject = [%bs.raw {|
{
  bar: {},
  baz: null,
  biz: 'baz',
  foo: '',
  net: [],
  nit: undefined,
  qux: {
    baz: 'boz',
    txi: ''
  }
}
|}];

let cleaned = CleanDeep.cleanDeep(jsObject);

Js.log(cleaned);
/* => { biz: 'baz', qux: { baz: 'boz' } } */

let cleanedKeepStrings = jsObject |> CleanDeep.cleanDeep(~emptyStrings=false);

Js.log(cleanedKeepStrings);
/* => { biz: 'baz', foo: '', qux: { baz: 'boz', txi: '' } } */

Contribute

If you find bugs or there are updates in clean-deep, feel free to open an issue or PR. If you are upgrading any dependencies, please use yarn so yarn.lock is updated.

You can’t perform that action at this time.