2.0.0 • Published 3 years ago

bs-clean-deep v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

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: '' } } */

let cleanedCustomValues = jsObject |> CleanDeep.cleanDeep(~cleanValues=[|"baz"|]);

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

See also example-project.

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.

2.0.0

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0

5 years ago