Socket
Socket
Sign inDemoInstall

prettyjson

Package Overview
Dependencies
1
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.1 to 0.8.0

6

History.md

@@ -0,1 +1,7 @@

### 0.8.0 — *February 23, 2013*
* Fix: ENV vars were not being used correctly
* Add an option to change the color of the strings
* Minor codestyle improvements
### 0.7.1 — *October 29, 2012*

@@ -2,0 +8,0 @@

7

lib/prettyjson.js

@@ -29,2 +29,3 @@ // Package for formatting JSON data in a coloured

// dashColor: 'red', // Color for the dashes in arrays
// stringColor: 'grey', // Color for strings
// defaultIndentation: 2 // Indentation on nested objects

@@ -45,2 +46,4 @@ // }

options.stringColor = options.stringColor || null;
// Initialize the output (it's an array of lines)

@@ -61,3 +64,3 @@ var output = [];

// Print strings in regular terminal color
return input;
return options.stringColor ? input[options.stringColor] : input;
}

@@ -182,4 +185,4 @@

// Call the real render() method
output += exports.render(parsedData);
output += exports.render(parsedData, options);
return output;
};

@@ -5,3 +5,3 @@ {

"description": "Package for formatting JSON data in a coloured YAML-style, perfect for CLI output",
"version": "0.7.1",
"version": "0.8.0",
"homepage": "http://rafeca.com/prettyjson",

@@ -8,0 +8,0 @@ "keywords": [

@@ -48,6 +48,6 @@ # prettyjson [![Build Status](https://secure.travis-ci.org/rafeca/prettyjson.png)](http://travis-ci.org/rafeca/prettyjson)

```bash
$ PRETTYJSON_KEYS=red PRETTYJSON_DASH=blue prettyjson package.json
$ PRETTYJSON_KEYS=red PRETTYJSON_DASH=blue PRETTYJSON_STRING=yellow prettyjson package.json
```
The available options are `PRETTYJSON_KEYS`, `PRETTYJSON_DASH` and `PRETTYJSON_INDENT`.
The available options are `PRETTYJSON_KEYS`, `PRETTYJSON_DASH`, `PRETTYJSON_STRING` and `PRETTYJSON_INDENT`.

@@ -60,3 +60,3 @@ ## Using it (from Node.js)

var prettyjson = require('prettyjson');
var data = {

@@ -73,3 +73,3 @@ username: 'rafeca',

And will output:
![Example 4](http://rafeca.com/prettyjson/images/example1.png)

@@ -91,4 +91,5 @@

console.log(prettyjson.render(data, {
keysColor: 'rainbow',
dashColor: 'magenta'
keysColor: 'rainbow',
dashColor: 'magenta',
stringColor: 'white'
}));

@@ -95,0 +96,0 @@ ```

@@ -1,4 +0,2 @@

var prettyjson = process.env.EXPRESS_COV
? require('../lib-cov/prettyjson')
: require('../lib/prettyjson');
var prettyjson = process.env.EXPRESS_COV ? require('../lib-cov/prettyjson') : require('../lib/prettyjson');
var should = require('should');

@@ -10,3 +8,3 @@

var input = 'This is a string'
var input = 'This is a string';
var output = prettyjson.render(input);

@@ -19,3 +17,3 @@

var input = 'This is a string'
var input = 'This is a string';
var output = prettyjson.render(input, {}, 4);

@@ -47,3 +45,3 @@

' ' + '- '.green + input[1][1],
'- '.green + input[2],
'- '.green + input[2]
].join('\n'));

@@ -59,3 +57,3 @@ });

'param1: '.green + 'first string',
'param2: '.green + 'second string',
'param2: '.green + 'second string'
].join('\n'));

@@ -73,3 +71,3 @@ });

' ' + 'subparam2: '.green + 'another string',
'second_param: '.green + 'second string',
'second_param: '.green + 'second string'
].join('\n'));

@@ -85,3 +83,3 @@ });

'very_large_param: '.green + 'first string',
'param: '.green + ' second string',
'param: '.green + ' second string'
].join('\n'));

@@ -132,3 +130,3 @@ });

'param1: '.blue + 'first string',
'param2: '.blue + 'second string',
'param2: '.blue + 'second string'
].join('\n'));

@@ -143,3 +141,3 @@ });

'param_long: '.rainbow + 'first string',
'param2: '.rainbow + ' second string',
'param2: '.rainbow + ' second string'
].join('\n'));

@@ -155,3 +153,3 @@ });

' ' + '- '.green + 'first string',
' ' + '- '.green + 'second string',
' ' + '- '.green + 'second string'
].join('\n'));

@@ -168,2 +166,12 @@ });

});
it("should allow to configure colors for strings", function() {
var input = {param1: 'first string', param2: 'second string'};
var output = prettyjson.render(input, {keysColor: 'blue', stringColor: 'red'});
output.should.equal([
'param1: '.blue + 'first string'.red,
'param2: '.blue + 'second string'.red
].join('\n'));
});
});

@@ -232,2 +240,7 @@

});
it('should be able to accept the options parameter', function(){
var output = prettyjson.renderString('{"test": "OK"}', {stringColor: 'red'});
output.should.equal('test: '.green + 'OK'.red);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc