Prettifies any javascript object in your console
npm install fmt-objfmt-obj [![Build status][travis-image]][travis-url] [![NPM version][version-image]][version-url] [![Dependency Status][david-image]][david-url] [![License][license-image]][license-url] [![Js Standard Style][standard-image]][standard-url]:lipstick: Prettifies any javascript object in your console. Make it look awesome!
Screenshot

> Also check out the CLI version made by @Kikobeats
- Circular reference support :sparkles:
- Allows for custom formatting
- Supports any arbitrary javascript token (functions, strings, numbers, arrays, you name it!)
``sh`
npm install --save fmt-obj
Or even better
`sh`
yarn add fmt-obj
`js
const format = require('fmt-obj')
console.log(format({
message: 'hello world',
dev: true,
awesomeness: 9.99,
body: {
these: null,
are: 'string',
some: 12,
props: false
}
}))
`
Prettifies obj with optional depth.
#### obj
Any arbitrary javascript object.
#### depth (optional)
Colapses all properties deeper than specified by depth.
Create a custom format function if you need more control of how you want to format the tokens.
#### opts.formatter (optional)
fmt-obj uses chalk for it's default format function. A formatter is mostly used for colors but can be used to manipulate anything.
Example with rounding numbers
`js`
const format = createFormatter({ number: Math.round })
format({ num: 12.49 }) // -> num: 12
The following tokens are available:
* punctuation - The characters sorrounding your data: : and "true
* literal - Either , false, null or undefined[Function {name}]
* annotation - Type annotation for errors, functions and circular references like
* property
* string
* number
Example with a custom color map
`js
const { createFormatter } = require('fmt-obj')
const format = createFormatter({
offset: 4,
formatter: {
punctuation: chalk.cyan,
annotation: chalk.red,
property: chalk.yellow,
literal: chalk.blue,
number: chalk.green,
string: chalk.bold
}
})
`
#### opts.offset (optional)
The amount of left whitespace between the property key and all of it's sub-properties.
_(Because package discovery is hard)_
* pretty-format` by @thejameskyle for additional ES6 type support (WeakMap, WeakSet, Symbol etc.) and more consistent output.
fmt-obj © Fabian Eichenberger, Released under the MIT License.
Authored and maintained by Fabian Eichenberger with help from contributors (list).
> GitHub @queckezz · Twitter @queckezz
[travis-image]: https://img.shields.io/travis/queckezz/fmt-obj.svg?style=flat-square
[travis-url]: https://travis-ci.org/queckezz/fmt-obj
[version-image]: https://img.shields.io/npm/v/fmt-obj.svg?style=flat-square
[version-url]: https://npmjs.org/package/fmt-obj
[david-image]: http://img.shields.io/david/queckezz/fmt-obj.svg?style=flat-square
[david-url]: https://david-dm.org/queckezz/fmt-obj
[standard-image]: https://img.shields.io/badge/code-standard-brightgreen.svg?style=flat-square
[standard-url]: https://github.com/feross/standard
[license-image]: http://img.shields.io/npm/l/fmt-obj.svg?style=flat-square
[license-url]: ./license