Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikaello/rescript-clean-deep
ReScript bindings for clean-deep: remove empty or nullable values from javascript objects
https://github.com/mikaello/rescript-clean-deep
javascript-utility rescript rescript-bindings
Last synced: 23 days ago
JSON representation
ReScript bindings for clean-deep: remove empty or nullable values from javascript objects
- Host: GitHub
- URL: https://github.com/mikaello/rescript-clean-deep
- Owner: mikaello
- License: mit
- Created: 2019-02-26T16:34:59.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-09-13T12:13:41.000Z (4 months ago)
- Last Synced: 2024-10-11T12:04:04.349Z (3 months ago)
- Topics: javascript-utility, rescript, rescript-bindings
- Language: ReScript
- Homepage:
- Size: 578 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rescript-clean-deep
[![NPM version](http://img.shields.io/npm/v/rescript-clean-deep.svg)](https://www.npmjs.org/package/rescript-clean-deep)
[![Build Status](https://app.travis-ci.com/mikaello/rescript-clean-deep.svg?branch=master)](https://app.travis-ci.com/github/mikaello/rescript-clean-deep)ReScript bindings for [clean-deep](https://github.com/nunofgs/clean-deep), a library for
removing empty or nullable values from javascript objects.## Getting started
```
yarn add rescript-clean-deep
```Then add `rescript-clean-deep` as a dependency to `bsconfig.json`:
```diff
"bs-dependencies": [
+ "rescript-clean-deep"
]
```## Example
```reason
open RescriptCleanDeep;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](./example).
## Contribute
If you find bugs or there are updates in
[clean-deep](https://github.com/nunofgs/clean-deep), feel free to open an issue
or PR. If you are upgrading any dependencies, please use yarn so `yarn.lock` is
updated.