Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/debitoor/groom
Node module. JSON.parse(JSON.stringify(myObject)) and remove all nulls and empty strings
https://github.com/debitoor/groom
Last synced: 12 days ago
JSON representation
Node module. JSON.parse(JSON.stringify(myObject)) and remove all nulls and empty strings
- Host: GitHub
- URL: https://github.com/debitoor/groom
- Owner: debitoor
- Created: 2015-02-10T08:33:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-19T07:26:51.000Z (over 9 years ago)
- Last Synced: 2024-10-14T11:07:53.418Z (about 1 month ago)
- Language: JavaScript
- Size: 238 KB
- Stars: 8
- Watchers: 41
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# groom [![Build Status](https://travis-ci.org/e-conomic/groom.svg?branch=master)](https://travis-ci.org/e-conomic/groom)
[![npm package](https://nodei.co/npm/groom.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/groom/)
Does JSON.parse(JSON.stringify(myObject)) and removes all nulls, undefined and empty strings.
```js
var groom = require('groom');var o = {
a: 1,
b: '',
c: null,
d: undefined,
e: [
null,
undefined,
'test'
],
f: new Date(0),
g: /test/
};
console.log(groom(o));
//output:
{
a: 1,
e: ["test"],
f: '1970-01-01T00:00:00.000Z',
g: {}
}
```Dates are .toString()'ed and regExp'es are turned into the empty object `{}`.
The original object stays the same. A copy without null, undefined and empty string is created.