pretty-format
Advanced tools
Comparing version 4.3.1 to 18.0.0
{ | ||
"name": "pretty-format", | ||
"version": "4.3.1", | ||
"version": "18.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/jest.git" | ||
}, | ||
"license": "BSD-3-Clause", | ||
"description": "Stringify any JavaScript value.", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"main": "build/index.js", | ||
"author": "James Kyle <me@thejameskyle.com>", | ||
"keywords": [], | ||
"repository": "https://github.com/thejameskyle/pretty-format.git", | ||
"bugs": "https://github.com/thejameskyle/pretty-format/issues", | ||
"homepage": "https://github.com/thejameskle/pretty-format", | ||
"scripts": { | ||
"test": "jest", | ||
"test": "../../packages/jest-cli/bin/jest.js", | ||
"perf": "node perf/test.js" | ||
}, | ||
"jest": { | ||
"testEnvironment": "node", | ||
"verbose": true | ||
}, | ||
"devDependencies": { | ||
"chalk": "^1.1.3", | ||
"jest": "^15.1.1", | ||
"left-pad": "^1.1.1", | ||
"react": "15.3.0" | ||
"dependencies": { | ||
"ansi-styles": "^2.2.1" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# pretty-format [![Travis build status](http://img.shields.io/travis/thejameskyle/pretty-format.svg?style=flat)](https://travis-ci.org/thejameskyle/pretty-format) | ||
# pretty-format | ||
@@ -13,3 +13,3 @@ > Stringify any JavaScript value. | ||
```sh | ||
$ npm install pretty-format | ||
$ yarn add pretty-format | ||
``` | ||
@@ -20,3 +20,3 @@ | ||
```js | ||
var prettyFormat = require('pretty-format'); | ||
const prettyFormat = require('pretty-format'); | ||
@@ -55,2 +55,41 @@ var obj = { property: {} }; | ||
### API | ||
```js | ||
console.log(prettyFormat(object)); | ||
console.log(prettyFormat(object, options)); | ||
``` | ||
Options: | ||
* **`callToJSON`**<br> | ||
Type: `boolean`, default: `true`<br> | ||
Call `toJSON()` on passed object. | ||
* **`indent`**<br> | ||
Type: `number`, default: `2`<br> | ||
Number of spaces for indentation. | ||
* **`maxDepth`**<br> | ||
Type: `number`, default: `Infinity`<br> | ||
Print only this number of levels. | ||
* **`min`**<br> | ||
Type: `boolean`, default: `false`<br> | ||
Print without whitespace. | ||
* **`plugins`**<br> | ||
Type: `array`, default: `[]`<br> | ||
Plugins (see the next section). | ||
* **`printFunctionName`**<br> | ||
Type: `boolean`, default: `true`<br> | ||
Print function names or just `[Function]`. | ||
* **`escapeRegex`**<br> | ||
Type: `boolean`, default: `false`<br> | ||
Escape special characters in regular expressions. | ||
* **`highlight`**<br> | ||
Type: `boolean`, default: `false`<br> | ||
Highlight syntax for terminal (works only with `ReactTestComponent` and `ReactElement` plugins. | ||
* **`theme`**<br> | ||
Type: `object`, default: `{tag: 'cyan', content: 'reset'...}`<br> | ||
Syntax highlight theme.<br> | ||
Uses [ansi-styles colors](https://github.com/chalk/ansi-styles#colors) + `reset` for no color.<br> | ||
Available types: `tag`, `content`, `prop` and `value`. | ||
### Plugins | ||
@@ -61,7 +100,7 @@ | ||
```js | ||
var fooPlugin = { | ||
test: function(val) { | ||
const fooPlugin = { | ||
test(val) { | ||
return val && val.hasOwnProperty('foo'); | ||
}, | ||
print: function(val, print, indent) { | ||
print(val, print, indent) { | ||
return 'Foo: ' + print(val.foo); | ||
@@ -71,3 +110,3 @@ } | ||
var obj = { foo: { bar: {} } }; | ||
const obj = {foo: {bar: {}}}; | ||
@@ -85,12 +124,12 @@ prettyFormat(obj, { | ||
```js | ||
var prettyFormat = require('pretty-format'); | ||
var reactTestPlugin = require('pretty-format/plugins/ReactTestComponent'); | ||
var reactElementPlugin = require('pretty-format/plugins/ReactElement'); | ||
const prettyFormat = require('pretty-format'); | ||
const reactTestPlugin = require('pretty-format/build/plugins/ReactTestComponent'); | ||
const reactElementPlugin = require('pretty-format/build/plugins/ReactElement'); | ||
var React = require('react'); | ||
var renderer = require('react/lib/ReactTestRenderer'); | ||
const React = require('react'); | ||
const renderer = require('react-test-renderer'); | ||
var jsx = React.createElement('h1', null, 'Hello World'); | ||
const element = React.createElement('h1', null, 'Hello World'); | ||
prettyFormat(renderer.create(jsx).toJSON(), { | ||
prettyFormat(renderer.create(element).toJSON(), { | ||
plugins: [reactTestPlugin, reactElementPlugin] | ||
@@ -97,0 +136,0 @@ }); |
Sorry, the diff of this file is not supported yet
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
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
286019
0
9
1
1755
135
0
1
2
+ Addedansi-styles@^2.2.1
+ Addedansi-styles@2.2.1(transitive)