Socket
Book a DemoInstallSign in
Socket

groom

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

groom

JSON.parse(JSON.stringify(myObject)) and remove all nulls, undefined and empty strings

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
95
6.74%
Maintainers
2
Weekly downloads
 
Created
Source

groom Build Status

npm package

Does JSON.parse(JSON.stringify(myObject)) and removes all nulls, undefined and empty strings.

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.

Keywords

filter

FAQs

Package last updated on 09 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts