Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc