{"id":13658935,"url":"https://github.com/queckezz/fmt-obj","last_synced_at":"2025-05-15T21:34:22.776Z","repository":{"id":38206053,"uuid":"82183462","full_name":"queckezz/fmt-obj","owner":"queckezz","description":"Stringifies any javascript object in your console for CLI inspection  :sparkles: ","archived":false,"fork":false,"pushed_at":"2017-05-22T06:24:46.000Z","size":91,"stargazers_count":444,"open_issues_count":2,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-05T19:06:11.654Z","etag":null,"topics":["awesome","fmt","format","formatter","object","pretty"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/queckezz.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-16T13:27:37.000Z","updated_at":"2025-01-13T18:30:17.000Z","dependencies_parsed_at":"2022-08-19T10:02:11.911Z","dependency_job_id":null,"html_url":"https://github.com/queckezz/fmt-obj","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queckezz%2Ffmt-obj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queckezz%2Ffmt-obj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queckezz%2Ffmt-obj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/queckezz%2Ffmt-obj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/queckezz","download_url":"https://codeload.github.com/queckezz/fmt-obj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253433295,"owners_count":21907767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["awesome","fmt","format","formatter","object","pretty"],"created_at":"2024-08-02T05:01:03.898Z","updated_at":"2025-05-15T21:34:22.642Z","avatar_url":"https://github.com/queckezz.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Output"],"sub_categories":[],"readme":"\n# `fmt-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]\n\n:lipstick: Prettifies any javascript object in your console. Make it look awesome!\n\n**Screenshot**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./intro.png\" /\u003e\n\u003c/p\u003e\n\n\u003csub\u003e\u003ca href='./example.js'\u003eView Example\u003c/a\u003e\u003c/sub\u003e\n\n\u003e Also check out the [`CLI version`](https://github.com/Kikobeats/fmt-obj-cli) made by [@Kikobeats](https://github.com/Kikobeats)\n\n## Features\n\n- Circular reference support :sparkles:\n- Allows for custom formatting\n- Supports any arbitrary javascript token (functions, strings, numbers, arrays, you name it!)\n\n## Installation\n\n```sh\nnpm install --save fmt-obj\n```\n\nOr even better\n\n```sh\nyarn add fmt-obj\n```\n\n## Import and Usage Example\n\n```js\nconst format = require('fmt-obj')\n\nconsole.log(format({\n  message: 'hello world',\n  dev: true,\n  awesomeness: 9.99,\n  body: {\n    these: null,\n    are: 'string',\n    some: 12,\n    props: false\n  }\n}))\n```\n\n## API\n\n### `format(obj, depth = Infinity)`\n\nPrettifies `obj` with optional `depth`.\n\n#### `obj`\n\nAny arbitrary javascript object.\n\n#### `depth` (optional)\n\nColapses all properties deeper than specified by `depth`.\n\n### `createFormatter({ offset = 2, formatter = identityFormatter })`\n\nCreate a custom format function if you need more control of *how* you want to format the tokens.\n\n#### `opts.formatter` (optional)\n\n`fmt-obj` uses [`chalk`](https://github.com/chalk/chalk) for it's default format function. A formatter is mostly used for colors but can be used to manipulate anything.\n\n**Example with rounding numbers**\n```js\nconst format = createFormatter({ number: Math.round })\nformat({ num: 12.49 }) // -\u003e num: 12\n```\n\nThe following tokens are available:\n\n* **punctuation** - The characters sorrounding your data: `:` and `\"`\n* **literal** - Either `true`, `false`, `null` or `undefined`\n* **annotation** - Type annotation for errors, functions and circular references like `[Function {name}]`\n* **property**\n* **string**\n* **number**\n\n**Example with a custom color map**\n```js\nconst { createFormatter } = require('fmt-obj')\n\nconst format = createFormatter({\n  offset: 4,\n\n  formatter: {\n    punctuation: chalk.cyan,\n    annotation: chalk.red,\n    property: chalk.yellow,\n    literal: chalk.blue,\n    number: chalk.green,\n    string: chalk.bold\n  }\n})\n```\n\n#### `opts.offset` (optional)\n\nThe amount of left whitespace between the property key and all of it's sub-properties.\n\n## Similar packages\n\n_(Because package discovery is hard)_\n\n* [`pretty-format`](https://github.com/facebook/jest/tree/master/packages/pretty-format) by @thejameskyle for additional ES6 type support (WeakMap, WeakSet, Symbol etc.) and more consistent output.\n\n## Author\n\n**fmt-obj** © [Fabian Eichenberger](https://github.com/queckezz), Released under the [MIT](./license) License.\u003cbr\u003e\nAuthored and maintained by Fabian Eichenberger with help from contributors ([list](https://github.com/queckezz/fmt-obj/contributors)).\n\n\u003e GitHub [@queckezz](https://github.com/queckezz) · Twitter [@queckezz](https://twitter.com/queckezz)\n\n[travis-image]: https://img.shields.io/travis/queckezz/fmt-obj.svg?style=flat-square\n[travis-url]: https://travis-ci.org/queckezz/fmt-obj\n\n[version-image]: https://img.shields.io/npm/v/fmt-obj.svg?style=flat-square\n[version-url]: https://npmjs.org/package/fmt-obj\n\n[david-image]: http://img.shields.io/david/queckezz/fmt-obj.svg?style=flat-square\n[david-url]: https://david-dm.org/queckezz/fmt-obj\n\n[standard-image]: https://img.shields.io/badge/code-standard-brightgreen.svg?style=flat-square\n[standard-url]: https://github.com/feross/standard\n\n[license-image]: http://img.shields.io/npm/l/fmt-obj.svg?style=flat-square\n[license-url]: ./license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueckezz%2Ffmt-obj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqueckezz%2Ffmt-obj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqueckezz%2Ffmt-obj/lists"}