nicely-format

WebJar for nicely-format

License

License

MIT
Categories

Categories

ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

nicely-format
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

nicely-format
WebJar for nicely-format
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/avajs/pretty-format

Download nicely-format

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/nicely-format/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>nicely-format</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/nicely-format/
implementation 'org.webjars.npm:nicely-format:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/nicely-format/
implementation ("org.webjars.npm:nicely-format:1.1.0")
'org.webjars.npm:nicely-format:jar:1.1.0'
<dependency org="org.webjars.npm" name="nicely-format" rev="1.1.0">
  <artifact name="nicely-format" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='nicely-format', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "nicely-format" % "1.1.0"
[org.webjars.npm/nicely-format "1.1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : ansi-styles jar [2.2.1,3)
org.webjars.npm : esutils jar [2.0.2,3)

Project Modules

There are no modules declared in this project.

DEPRECATED

AVA no longer uses this fork. The repository is retained for posterity.


@ava/pretty-format Travis build status

Stringify any JavaScript value.

Installation

$ npm install @ava/pretty-format

Usage

var prettyFormat = require('pretty-format');

var obj = { property: {} };
obj.circularReference = obj;
obj[Symbol('foo')] = 'foo';
obj.map = new Map();
obj.map.set('prop', 'value');
obj.array = [1, NaN, Infinity];

console.log(prettyFormat(obj));

Result:

Object {
  "property": Object {},
  "circularReference": [Circular],
  "map": Map {
    "prop" => "value"
  },
  "array": Array [
    1,
    NaN,
    Infinity
  ],
  Symbol(foo): "foo"
}

Type Support

Object, Array, ArrayBuffer, DataView, Float32Array, Float64Array, Int8Array, Int16Array, Int32Array, Uint8Array, Uint8ClampedArray, Uint16Array, Uint32Array, arguments, Boolean, Date, Error, Function, Infinity, Map, NaN, null, Number, RegExp, Set, String, Symbol, undefined, WeakMap, WeakSet

API

console.log(prettyFormat(object));
console.log(prettyFormat(object, options));

Options:

  • callToJSON
    Type: boolean, default: true
    Call toJSON() on passed object.
  • indent
    Type: number, default: 2
    Number of spaces for indentation.
  • maxDepth
    Type: number, default: Infinity
    Print only this number of levels.
  • min
    Type: boolean, default: false
    Print without whitespace.
  • plugins
    Type: array, default: []
    Plugins (see the next section).
  • printFunctionName
    Type: boolean, default: true
    Print function names or just [Function].
  • escapeRegex
    Type: boolean, default: false
    Escape special characters in regular expressions.
  • highlight
    Type: boolean, default: false
    Highlight syntax for terminal (works only with ReactTestComponent and ReactElement plugins.
  • theme
    Type: object, default: {tag: 'cyan', content: 'reset'...}
    Syntax highlight theme.
    Uses ansi-styles colors + reset for no color.
    Available types: tag, content, prop and value.

Plugins

Pretty format also supports adding plugins:

var fooPlugin = {
  test: function(val) {
    return val && val.hasOwnProperty('foo');
  },
  print: function(val, print, indent) {
    return 'Foo: ' + print(val.foo);
  }
};

var obj = { foo: { bar: {} } };

prettyFormat(obj, {
  plugins: [fooPlugin]
});
// Foo: Object {
//   "bar": Object {}
// }

ReactTestComponent and ReactElement plugins

var prettyFormat = require('pretty-format');
var reactTestPlugin = require('pretty-format/plugins/ReactTestComponent');
var reactElementPlugin = require('pretty-format/plugins/ReactElement');

var React = require('react');
var renderer = require('react-test-renderer');

var jsx = React.createElement('h1', null, 'Hello World');

prettyFormat(renderer.create(jsx).toJSON(), {
  plugins: [reactTestPlugin, reactElementPlugin]
});
// <h1>
//   Hello World
// </h1>
org.webjars.npm

AVA

Node.js test runner that lets you develop with confidence 🚀

Versions

Version
1.1.0