New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@types/json-stringify-safe

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/json-stringify-safe

TypeScript definitions for json-stringify-safe

  • 5.0.3
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • ts5.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @types/json-stringify-safe?

@types/json-stringify-safe provides TypeScript type definitions for the json-stringify-safe package, which is a JSON.stringify wrapper that handles circular references safely.

What are @types/json-stringify-safe's main functionalities?

Safe JSON Stringification

This feature allows you to safely stringify objects that contain circular references without throwing an error. The code sample demonstrates how to use json-stringify-safe to handle an object with circular references.

const stringifySafe = require('json-stringify-safe');
const circularObj = {};
circularObj.circularRef = circularObj;
circularObj.list = [circularObj, circularObj];
console.log(stringifySafe(circularObj));

Custom Replacer Function

This feature allows you to pass a custom replacer function to modify the behavior of the stringification process. The code sample demonstrates how to exclude a specific key from the final JSON string.

const stringifySafe = require('json-stringify-safe');
const obj = { a: 1, b: 2, c: 3 };
function replacer(key, value) {
  if (key === 'b') return undefined;
  return value;
}
console.log(stringifySafe(obj, replacer));

Custom Indentation

This feature allows you to specify the number of spaces to use for indentation in the output JSON string. The code sample demonstrates how to format the JSON string with a 2-space indentation.

const stringifySafe = require('json-stringify-safe');
const obj = { a: 1, b: 2, c: 3 };
console.log(stringifySafe(obj, null, 2));

Other packages similar to @types/json-stringify-safe

FAQs

Package last updated on 07 Nov 2023

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