All Projects → queckezz → Fmt Obj

queckezz / Fmt Obj

Licence: mit
Stringifies any javascript object in your console for CLI inspection ✨

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Fmt Obj

Kibana Object Format
A Kibana plugin for displaying objects and arrays of objects.
Stars: ✭ 100 (-76.64%)
Mutual labels:  object, formatter
format-date
📆 A small library (around 400 B when gziped & minified) to format JavaScript `Date` object using same tokens as moment.
Stars: ✭ 25 (-94.16%)
Mutual labels:  formatter, format
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (-92.29%)
Mutual labels:  formatter, format
Translatedjs
Internationalization and localization for JavaScript and Node.js
Stars: ✭ 17 (-96.03%)
Mutual labels:  formatter, format
teks
Easily get custom go template based outputs to your command-line tool. Like in docker/kubernetes
Stars: ✭ 41 (-90.42%)
Mutual labels:  formatter, format
Uncrustify
Code beautifier
Stars: ✭ 2,442 (+470.56%)
Mutual labels:  formatter, format
googlejavaformat-action
GitHub Action that formats Java files following Google Style guidelines
Stars: ✭ 66 (-84.58%)
Mutual labels:  formatter, format
Brazilian Utils
Utils library for specific Brazilian businesses
Stars: ✭ 1,023 (+139.02%)
Mutual labels:  formatter, format
AutoFormatInputWatcher
This repository contains input watcher for auto formatting digits in edit text
Stars: ✭ 15 (-96.5%)
Mutual labels:  formatter, format
unicode-formatter
Convert portions of text to fancy text using unicode fonts for use on Twitter and other sites that don't support rich text
Stars: ✭ 31 (-92.76%)
Mutual labels:  formatter, format
winston-dev-console
Winston@3 console format aimed to improve development UX
Stars: ✭ 88 (-79.44%)
Mutual labels:  formatter, format
pretty-remarkable
Plugin for prettifying markdown with https://github.com/jonschlinkert/remarkable using custom renderer rules.
Stars: ✭ 22 (-94.86%)
Mutual labels:  formatter, format
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (-95.56%)
Mutual labels:  formatter, format
python-yamlable
A thin wrapper of PyYaml to convert Python objects to YAML and back
Stars: ✭ 28 (-93.46%)
Mutual labels:  object, format
Simple-YAML
A Java API that provides an easy-to-use way to store data using the YAML format.
Stars: ✭ 68 (-84.11%)
Mutual labels:  object, format
Rustfmt
Format Rust code
Stars: ✭ 4,049 (+846.03%)
Mutual labels:  formatter
Autopep8
A tool that automatically formats Python code to conform to the PEP 8 style guide.
Stars: ✭ 3,967 (+826.87%)
Mutual labels:  formatter
Sublimejsprettier
JsPrettier is a Sublime Text Plug-in for Prettier, the opinionated code formatter.
Stars: ✭ 355 (-17.06%)
Mutual labels:  format
React Element To Jsx String
Turn a ReactElement into the corresponding JSX string
Stars: ✭ 349 (-18.46%)
Mutual labels:  format
Prettier Vscode
Visual Studio Code extension for Prettier
Stars: ✭ 4,085 (+854.44%)
Mutual labels:  formatter

fmt-obj Build status NPM version Dependency Status License Js Standard Style

💄 Prettifies any javascript object in your console. Make it look awesome!

Screenshot

View Example

Also check out the CLI version made by @Kikobeats

Features

  • Circular reference support ✨
  • Allows for custom formatting
  • Supports any arbitrary javascript token (functions, strings, numbers, arrays, you name it!)

Installation

npm install --save fmt-obj

Or even better

yarn add fmt-obj

Import and Usage Example

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
  }
}))

API

format(obj, depth = Infinity)

Prettifies obj with optional depth.

obj

Any arbitrary javascript object.

depth (optional)

Colapses all properties deeper than specified by depth.

createFormatter({ offset = 2, formatter = identityFormatter })

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

const format = createFormatter({ number: Math.round })
format({ num: 12.49 }) // -> num: 12

The following tokens are available:

  • punctuation - The characters sorrounding your data: : and "
  • literal - Either true, false, null or undefined
  • annotation - Type annotation for errors, functions and circular references like [Function {name}]
  • property
  • string
  • number

Example with a custom color map

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.

Similar packages

(Because package discovery is hard)

Author

fmt-obj © Fabian Eichenberger, Released under the MIT License.
Authored and maintained by Fabian Eichenberger with help from contributors (list).

GitHub @queckezz · Twitter @queckezz

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].