Socket
Socket
Sign inDemoInstall

pretty-format

Package Overview
Dependencies
1
Maintainers
2
Versions
236
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.3.1 to 18.0.0

build/index.js

27

package.json
{
"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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc