
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
stringify-x
Advanced tools
Enhanced object stringifier for JavaScript
stringify-x works similar to JSON.stringify with the following enhancements:
stringify(obj, maxDepth); // stringifies obj up to optional maxDepth
var stringify = require("stringify-x");
var _object = {
_boolean: false,
_string: "Hello",
_date: new Date(),
_number: 123,
_null: null,
_undefined: undefined,
_regexp: /abc[0-9]+/g,
_array: [1, 2, "three"],
_function: function hello() {},
_object: {
_boolean: true,
_string: "World",
_date: new Date(2011, 10, 30),
_number: -123.123456789,
_regexp: new RegExp('a-z'),
_array: ["a", "b", "c"],
_function: function() {},
_object: {
_boolean: true,
_string: "Hello World",
_date: new Date(2011, 10, 30),
_number: -123.123456789,
_regexp: new RegExp('a-z'),
_array: ["a", "b", "c"],
_function: function() {}
}
}
}
// use custom maxDepth of 1
console.log(stringify(_object, 1));
// use default maxDepth (10)
console.log(stringify(_object));
console.log("implicit undefined value: " + stringify());
console.log("undefined value: " + stringify(undefined));
console.log('"undefined" string: ' + stringify("undefined"));
console.log("null value: " + stringify(null));
console.log('"null" string: ' + stringify("null"));
Result:
{_boolean: false,_string: "Hello",_date: Mon Sep 12 2016 13:53:07 GMT-0700 (PDT),_number: 123,_null: *null*,_undefined: *undefined*,_regexp: /abc[0-9]+/g,_array: "1,2,three",_function: hello(),_object: "[object Object]"}
{_boolean: false,_string: "Hello",_date: Mon Sep 12 2016 13:53:07 GMT-0700 (PDT),_number: 123,_null: *null*,_undefined: *undefined*,_regexp: /abc[0-9]+/g,_array: [1,2,"three"],_function: hello(),_object: {_boolean: true,_string: "World",_date: Wed Nov 30 2011 00:00:00 GMT-0800 (PST),_number: -123.123456789,_regexp: /a-z/,_array: ["a","b","c"],_function: (),_object: {_boolean: true,_string: "Hello World",_date: Wed Nov 30 2011 00:00:00 GMT-0800 (PST),_number: -123.123456789,_regexp: /a-z/,_array: ["a","b","c"],_function: ()}}}
implicit undefined value: *undefined*
undefined value: *undefined*
"undefined" string: "undefined"
null value: *null*
"null" string: "null"
npm install stringify-x --save
FAQs
Enhanced object stringifier for JavaScript
We found that stringify-x demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.