Socket
Socket
Sign inDemoInstall

stringify-object

Package Overview
Dependencies
Maintainers
6
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stringify-object

Stringify an object/array like JSON.stringify just without all the double-quotes


Version published
Weekly downloads
5.6M
decreased by-19.63%
Maintainers
6
Weekly downloads
 
Created

What is stringify-object?

The stringify-object npm package is used to stringify an object into a string format that is more readable than JSON.stringify, especially for multi-line strings and functions. It provides options to customize the output, such as indentation, single quotes, and filtering of object properties.

What are stringify-object's main functionalities?

Stringify an object with custom indentation

This feature allows you to convert an object to a string with a specified indentation for better readability. The code sample demonstrates how to use a two-space indentation.

const stringifyObject = require('stringify-object');
const obj = {foo: 'bar', 'arr': [1, 2, 3]};
console.log(stringifyObject(obj, {
    indent: '  '
}));

Stringify an object using single quotes

This feature allows you to stringify an object using single quotes instead of double quotes for string values. The code sample shows how to enable this option.

const stringifyObject = require('stringify-object');
const obj = {foo: 'bar'};
console.log(stringifyObject(obj, {
    singleQuotes: true
}));

Filter properties during stringification

This feature allows you to filter out properties from the resulting string based on a custom function. The code sample demonstrates excluding the 'baz' property from the stringified output.

const stringifyObject = require('stringify-object');
const obj = {foo: 'bar', baz: 'qux'};
console.log(stringifyObject(obj, {
    filter: (obj, prop, value) => prop !== 'baz'
}));

Other packages similar to stringify-object

Keywords

FAQs

Package last updated on 13 Jun 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc