Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettyjson

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettyjson - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

2

Authors.md

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

Go to the [https://github.com/rafeca/prettyjson/graphs/contributors](GitHub contributors graph page)
Go to the [GitHub contributors graph page](https://github.com/rafeca/prettyjson/graphs/contributors)
to see the list of contributors.

@@ -68,6 +68,14 @@ 'use strict';

var indentLines = function(string, spaces){
var colorMultilineString = function(options, line) {
if (options.multilineStringColor === null || options.noColor) {
return line;
} else {
return colors[options.multilineStringColor](line);
}
};
var indentLines = function(string, spaces, options){
var lines = string.split('\n');
lines = lines.map(function(line){
return Utils.indent(spaces) + line;
return Utils.indent(spaces) + colorMultilineString(options, line);
});

@@ -85,5 +93,5 @@ return lines.join('\n');

return [
Utils.indent(indentation) + '"""',
indentLines(data, indentation + options.defaultIndentation),
Utils.indent(indentation) + '"""'
Utils.indent(indentation) + colorMultilineString(options, '"""'),
indentLines(data, indentation + options.defaultIndentation, options),
Utils.indent(indentation) + colorMultilineString(options, '"""')
];

@@ -192,7 +200,8 @@ }

// {
// emptyArrayMsg: '(empty)', // Rendered message on empty strings
// keysColor: 'blue', // Color for keys in hashes
// dashColor: 'red', // Color for the dashes in arrays
// stringColor: 'grey', // Color for strings
// defaultIndentation: 2 // Indentation on nested objects
// emptyArrayMsg: '(empty)', // Rendered message on empty strings
// keysColor: 'blue', // Color for keys in hashes
// dashColor: 'red', // Color for the dashes in arrays
// stringColor: 'grey', // Color for strings
// multilineStringColor: 'cyan' // Color for multiline strings
// defaultIndentation: 2 // Indentation on nested objects
// }

@@ -212,2 +221,3 @@ exports.render = function render(data, options, indentation) {

options.stringColor = options.stringColor || null;
options.multilineStringColor = options.multilineStringColor || null;

@@ -214,0 +224,0 @@ return renderToArray(data, options, indentation).join('\n');

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

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

@@ -35,3 +35,3 @@ "keywords": [

"dependencies": {
"colors": "^1.1.2",
"colors": "1.4.0",
"minimist": "^1.2.0"

@@ -38,0 +38,0 @@ },

@@ -50,3 +50,3 @@ # prettyjson [![Build Status](https://secure.travis-ci.org/rafeca/prettyjson.png)](http://travis-ci.org/rafeca/prettyjson) [![NPM version](https://badge.fury.io/js/prettyjson.png)](http://badge.fury.io/js/prettyjson) [![Coverage Status](https://coveralls.io/repos/rafeca/prettyjson/badge.png?branch=master)](https://coveralls.io/r/rafeca/prettyjson?branch=master)

# Change colors
$ prettyjson --string=red --keys=blue --dash=yellow --number=green package.json
$ prettyjson --string=red --multiline_string=cyan --keys=blue --dash=yellow --number=green package.json

@@ -108,3 +108,4 @@ # Do not use colors

dashColor: 'magenta',
stringColor: 'white'
stringColor: 'white',
multilineStringColor: 'cyan'
}));

@@ -111,0 +112,0 @@ ```

@@ -210,2 +210,16 @@ 'use strict';

it('should allow to configure colors for multiline strings', function() {
var input = 'first line string\nsecond line string';
var output = prettyjson.render(
input,
{multilineStringColor: 'red'}
);
output.should.equal([
colors.red('"""') ,
' ' + colors.red('first line string'),
' ' + colors.red('second line string'),
colors.red('"""')
].join('\n'));
});
it('should allow to not use colors', function() {

@@ -212,0 +226,0 @@ var input = {param1: 'first string', param2: ['second string']};

Sorry, the diff of this file is not supported yet

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