Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@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).
npm install @sinonjs/formatio
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]
formatio was released under BSD-3
FAQs
Human-readable object formatting
The npm package @sinonjs/formatio receives a total of 1,235,936 weekly downloads. As such, @sinonjs/formatio popularity was classified as popular.
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
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.