Skip to content

debitoor/groom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Node module. JSON.parse(JSON.stringify(myObject)) and remove all nulls and empty strings

Resources

Stars

Watchers

Forks

Packages

No packages published