Socket
Socket
Sign inDemoInstall

format-json

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-json - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

.npmrc

21

index.js
module.exports = (function() {
function json(o) { return JSON.stringify(o); }
var n = null

@@ -7,9 +8,21 @@ , leadOp = '\n$2$1 '

, format =
{ terse: function(o) { return JSON.stringify(o); }
{ terse: json
, plain: function(o, i) { return JSON.stringify(o, n, i == n ? 2 : i); }
, diffy: function(o) {
return format.plain(o)
.replace(tailOp, leadOp)
.replace(cuddle, '$1');
return format.plain(o).replace(tailOp, leadOp).replace(cuddle, '$1');
}
, space: function(o) {
return JSON.stringify(o, null, 1).replace(/\n */g, ' ');
}
, lines: function(o) {
if ('object' !== typeof o || o == null) return format.terse(o);
if ('[object Array]' === Object.prototype.toString.call(o))
return '[ '+ o.map(format.space).join('\n, ') + '\n]';
var res = '', sep = '{ ', key;
for (key in o) {
res += sep + json(key) +': '+ format.space(o[key]);
sep = '\n, ';
}
return res + '\n}';
}
}

@@ -16,0 +29,0 @@ ;

2

package.json
{ "name": "format-json"
, "version": "1.0.2"
, "version": "1.0.3"
, "author": "Johan Sundström <oyasumi@gmail.com>"

@@ -4,0 +4,0 @@ , "description": "A JSON formatter module for various text/plain serialization styles"

@@ -31,2 +31,8 @@ format-json

{"test":"for example","some":[{"nested":0,"things":[]},{}]}
> console.log(json.space(data));
{ "test": "for example", "some": [ { "nested": 0, "things": [] }, {} ] }
> console.log(json.lines(data));
{ "test": "for example"
, "some": [ { "nested": 0, "things": [] }, {} ]
}
```

@@ -33,0 +39,0 @@

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