Comparing version 0.0.22 to 0.0.23
{ | ||
"name": "main", | ||
"version": "0.0.22", | ||
"version": "0.0.23", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "description": "Provides useful tools for writing command line scripts", |
@@ -24,9 +24,16 @@ "use strict"; | ||
it('should handle Objects', function() { | ||
toolsSync.str({ foo: 'bar'}).should.equal( | ||
it('should handle Objects (pretty)', function() { | ||
toolsSync.str({ foo: 'bar'}, true).should.equal( | ||
'{\n "foo": "bar"\n}'); | ||
toolsSync.str(['foo']).should.equal( | ||
toolsSync.str(['foo'], true).should.equal( | ||
'[\n "foo"\n]'); | ||
}); | ||
it('should handle Objects (normal)', function() { | ||
toolsSync.str({ foo: 'bar'}).should.equal( | ||
'{"foo":"bar"}'); | ||
toolsSync.str(['foo']).should.equal( | ||
'["foo"]'); | ||
}); | ||
it('should handle anything else', function() { | ||
@@ -33,0 +40,0 @@ toolsSync.str(5).should.equal('5'); |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.str = function(thing) { | ||
exports.str = function(thing, prettify) { | ||
// If it's a string, get out of here! | ||
@@ -15,3 +15,8 @@ if (typeof thing === 'string') { return thing; } | ||
if (typeof thing === 'object') { | ||
try { var json = JSON.stringify(thing, null, 4); return json; } | ||
try { | ||
var json = prettify | ||
? JSON.stringify(thing, null, 4) | ||
: JSON.stringify(thing); | ||
return json; | ||
} | ||
catch (e) {} | ||
@@ -18,0 +23,0 @@ } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
33406
828
0