🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
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

to
0.11.0

.jshintrc

93

History.md

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

### 0.10.0 — *December 10, 2013*
* Add pretty printing of errors (by @mmalecki)
* Deprecate Node.js 0.6.x and 0.8.x
### 0.9.0 — *October 4, 2013*
* Checks for hasOwnProperty in function render (by @dlight)
### 0.8.1 — *March 11, 2013*
* Add compatibility for Node.js 0.10.0
* Update dependencies
### 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*
* Fix bug in 0.7.0 when input is an array
### 0.7.0 — *October 25, 2012*
* Allow having non-JSON characters at the beginning of the input string (ideal for curl -i)
* Add a renderString() method to be used by the CLI
* Change test reporter style to spec
* Upgrade dependencies to the last versions
### 0.6.0 — *June 29, 2012*
* Update dependencies to support Node.js v0.8
* Adding ability to use environmental variables
### 0.5.0 — *June 24, 2012*
* Updated dependencies, added support for Node.js up to 0.7.12
* Minor improvements in README file
* Add JSHint to the build process
* Add jake task to execute tests automatically
* Add test coverage info
### 0.4.0 — *February 24, 2012*
* Now prettyjson uses Mocha test framework instead of jasmine-node
* Fixed leak in a "key" variable
### 0.3.1 — *February 15, 2012*
* Modified website design
* Modify webpage link in package.json
### 0.3.0 — *January 24, 2012*
* Added CLI interface
* Now prettyjson package requires Nodejs 0.6.x
### 0.2.1 — *January 23, 2012*
* Fix: Bug when the JSON has attributes with booleans, integers or null values
### 0.2.0 — *January 22, 2012*
* Now using node-releasetools for the release process
* Disabled Node.js 0.6 from Travis CI temporally
* Minor copy in Readme.md
### 0.1.4 — *December 1, 2011*
* Added contributors to the Readme file
### 0.1.3 — *November 17, 2011*
* Fixed the GitHub publishing of tags in the jake task
* Updated package.json to make it compatible with Node.js 0.6.x
* Updated travis YAML file to use the new Node.js support on Travis
### 0.1.2 — *November 14, 2011*
* Updated Jakefile with tasks to automate publishing new versions
### 0.1.1 — *October 11, 2011*
* Added changelog jake task to add changelog automatically
* The library version is retrieved from `package.json` file
### 0.1.0 — *October 10, 2011*
* Initial release
Go to [GitHub releases page](https://github.com/rafeca/prettyjson/releases) to
see the history of releases.

@@ -1,15 +0,8 @@

// Package for formatting JSON data in a coloured
// YAML-style, perfect for CLI output
'use strict';
// ### Export package
module.exports = exports;
// ### Module dependencies
var colors = require('colors');
var Utils = require('./utils');
var fs = require('fs');
require('colors');
var Utils = require('./utils');
// ### Package version
exports.version = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version;
exports.version = require('../package.json').version;

@@ -33,12 +26,10 @@ // ### Render function

exports.render = function render(data, options, indentation) {
"use strict";
// Default value for the indentation param
// Default values
indentation = indentation || 0;
// Default values for the options
options = options || {};
options.emptyArrayMsg = options.emptyArrayMsg || '(empty array)';
options.keysColor = options.keysColor || "green";
options.dashColor = options.dashColor || "green";
options.keysColor = options.keysColor || 'green';
options.dashColor = options.dashColor || 'green';
options.numberColor = options.numberColor || 'blue';
options.defaultIndentation = options.defaultIndentation || 2;

@@ -48,6 +39,5 @@

// Initialize the output (it's an array of lines)
var output = [];
// Helper function to detect if an object can be serializable directly
// Helper function to detect if an object can be directly serializable
var isSerializable = function(input) {

@@ -77,3 +67,3 @@ if (typeof input === 'string' || typeof input === 'boolean' ||

if (typeof input === 'number') {
return (input+'').blue;
return (input+'')[options.numberColor];
}

@@ -101,8 +91,8 @@ return (input+'');

// If the element of the array is an array or object, render it in next line
// If the element is an array or object, render it in next line
} else {
output.push(line);
output.push(
exports.render(element, options, indentation + options.defaultIndentation)
);
output.push(exports.render(
element, options, indentation + options.defaultIndentation
));
}

@@ -113,3 +103,3 @@ });

else if (typeof data === 'object') {
// Get the size of the longest index to render all the values on the same column
// Get the size of the longest index to align all the values
var maxIndexLength = Utils.getMaxIndexLength(data);

@@ -138,6 +128,5 @@ var key;

exports.render(
isError && i === 'stack'
? data[i].split('\n')
: data[i],
options, indentation + options.defaultIndentation
isError && i === 'stack' ? data[i].split('\n') : data[i],
options,
indentation + options.defaultIndentation
)

@@ -168,3 +157,2 @@ );

exports.renderString = function renderString(data, options, indentation) {
"use strict";

@@ -185,6 +173,8 @@ var output = '';

beginingOfJson = data.indexOf('{');
} else if (data.indexOf('{') < data.indexOf('[')) {
beginingOfJson = data.indexOf('{');
} else {
beginingOfJson = data.indexOf('{') < data.indexOf('[') ? data.indexOf('{') : data.indexOf('[');
beginingOfJson = data.indexOf('[');
}
output += data.substr(0, beginingOfJson) + "\n";
output += data.substr(0, beginingOfJson) + '\n';
data = data.substr(beginingOfJson);

@@ -201,4 +191,4 @@ }

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

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

"use strict";
'use strict';

@@ -15,3 +15,2 @@ /**

var maxWidth = 0;
var key;

@@ -18,0 +17,0 @@ Object.getOwnPropertyNames(input).forEach(function(key) {

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

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

@@ -20,3 +20,8 @@ "keywords": [

"scripts": {
"test": "./node_modules/mocha/bin/mocha --reporter spec"
"test": "mocha --reporter spec",
"testwin": "node ./node_modules/mocha/bin/mocha --reporter spec",
"jshint": "jshint lib/*.js",
"coverage": "istanbul cover _mocha --report lcovonly -- -R spec",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"changelog": "git log $(git describe --tags --abbrev=0)..HEAD --pretty='* %s' --first-parent"
},

@@ -33,10 +38,10 @@ "bin": {

"devDependencies": {
"releasetools": "0.4.1",
"step": "0.0.5",
"mocha": "1.8.1",
"should": "1.2.2",
"jake": "0.5.9",
"jshint": "1.1.0",
"jscoverage": "0.3.8"
"jshint": "~2.3.0",
"getversion": "~0.1.1",
"istanbul": "~0.2.4",
"coveralls": "~2.7.0",
"mocha-lcov-reporter": "0.0.1"
}
}

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

# 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)
# 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)

@@ -24,3 +24,3 @@ Package for formatting JSON data in a coloured YAML-style, perfect for CLI output.

![Example 1](http://rafeca.com/prettyjson/images/example3.png)
![Example 1](images/example3.png)

@@ -34,3 +34,3 @@ **Decode the stdin:** You can also pipe the result of a command (for example an HTTP request) to the CLI to see

![Example 2](http://rafeca.com/prettyjson/images/example4.png)
![Example 2](images/example4.png)

@@ -40,3 +40,3 @@ **Decode random strings:** if you call the CLI with no arguments, you'll get a prompt where you can past JSON strings

![Example 3](http://rafeca.com/prettyjson/images/example5.png)
![Example 3](images/example5.png)

@@ -75,3 +75,3 @@ If you install the package globally (with `npm install -g prettyjson`), the CLI will be installed automatically in your PATH

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

@@ -100,8 +100,4 @@ You can also configure the colors of the hash keys and array dashes

![Example 5](http://rafeca.com/prettyjson/images/example2.png)
![Example 5](images/example2.png)
## Annotated source
You can check the [annotated source](http://rafeca.com/prettyjson/prettyjson.html) for more information about how it works
## Running Tests

@@ -112,3 +108,3 @@

```bash
$ npm install --dev
$ npm install
```

@@ -122,2 +118,6 @@

You can check the package's [test coverage](http://rafeca.com/prettyjson/coverage.html) if you are one of those test paranoics
On windows, you can run the tests with:
```cmd
C:\git\prettyjson> npm run-script testwin
```

@@ -128,2 +128,12 @@ var prettyjson = process.env.EXPRESS_COV ? require('../lib-cov/prettyjson') : require('../lib/prettyjson');

it("should allow to configure colors for numbers", function() {
var input = {param1: 17, param2: 22.3};
var output = prettyjson.render(input, {numberColor: 'red'});
output.should.equal([
'param1: '.green + '17'.red,
'param2: '.green + '22.3'.red
].join('\n'));
});
it("should allow to configure rainbow as color", function() {

@@ -130,0 +140,0 @@ var input = {param_long: 'first string', param2: 'second string'};

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