Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@sinonjs/formatio
Advanced tools
The @sinonjs/formatio package is a utility for pretty-printing JavaScript values, particularly useful for producing human-readable output of complex objects and structures. It is often used in testing frameworks to format output for assertions and logs.
Pretty-printing objects
This feature allows the pretty-printing of objects into a string format that is easy to read, especially useful for debugging or displaying complex data structures in logs.
const formatio = require('@sinonjs/formatio');
const obj = { name: 'Alice', age: 25, details: { hobbies: ['reading', 'cycling'] } };
console.log(formatio.ascii(obj));
Custom depth for formatting
This feature enables control over how deep the formatting should go when converting objects to strings. It helps in avoiding too much verbosity by limiting the depth of object traversal.
const formatio = require('@sinonjs/formatio');
const obj = { name: 'Alice', age: 25, details: { hobbies: ['reading', 'cycling'], location: 'City' } };
console.log(formatio.ascii(obj, { maxDepth: 1 }));
pretty-format is a package developed by Facebook as part of the Jest testing framework. It offers similar functionality to @sinonjs/formatio by providing a way to serialize JavaScript objects into strings for snapshot testing. It supports plugins to handle different types of objects and is more extensible compared to @sinonjs/formatio.
util-inspect is a node module that provides an inspection function similar to Node.js core's util.inspect method. It is used for converting objects into strings for debugging purposes. While it shares similar basic functionality with @sinonjs/formatio, it is more tightly integrated with Node.js's core modules and might offer better performance in a Node.js environment.
The cheesy object formatter
Pretty formatting of arbitrary JavaScript values. Currently only supports ascii
formatting, suitable for command-line utilities. Like JSON.stringify
, it
formats objects recursively, but unlike JSON.stringify
, it can handle
regular expressions, functions, circular objects and more.
formatio
is a general-purpose library. It works in browsers (including old
and rowdy ones, like IE6) and Node. It will define itself as an AMD module if
you want it to (i.e. if there's a define
function available).
Documentation: https://sinonjs.github.io/formatio/
Support us with a monthly donation and help us continue our activities. [Become a backer]
Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]
samsam was released under BSD-3
FAQs
Human-readable object formatting
We found that @sinonjs/formatio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.