
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
fmt-obj
:lipstick: Prettifies any javascript object in your console. Make it look awesome!
Screenshot
Also check out the
CLI version
made by @Kikobeats
npm install --save fmt-obj
Or even better
yarn add fmt-obj
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
}
}))
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:
:
and "
true
, false
, null
or undefined
[Function {name}]
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.
(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).
FAQs
Prettifies any javascript object in your console
The npm package fmt-obj receives a total of 1,416 weekly downloads. As such, fmt-obj popularity was classified as popular.
We found that fmt-obj demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.