JSPM

pretty-format

2.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 98454147
  • Score
    100M100P100Q235931F
  • License MIT

Stringify any JavaScript value.

Package Exports

  • pretty-format

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pretty-format) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pretty-format Travis build status

Stringify any JavaScript value.

Supports objects, arrays (and typed arrays and array buffers), arguments, booleans, dates, errors, functions, Infinity, maps, NaN, null, numbers, regular expressions, sets, strings, symbols, undefined, weak maps, weak sets, and circular data structures.

Installation

$ npm install 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"
}