Socket
Socket
Sign inDemoInstall

json-truncate

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-truncate

A way to truncate a json object.


Version published
Weekly downloads
6.5K
increased by77.05%
Maintainers
1
Weekly downloads
 
Created
Source

json-truncate

A way to truncate a json object. Useful for circular referenced objects.

Status

npm Travis Coverage Status Dependency Status devDependency Status js-standard-style semantic-release npm

Install

npm install json-truncate --save

Usage

// You can add this as a static function on JSON.
JSON.truncate = require('json-truncate');

console.log(JSON.truncate(SomeDeepObject, 10));

//OR specify a replacement string for truncated values

console.log(JSON.truncate(SomeDeepObject, 10, {replace: '[Truncated]'}));

Returns

You will get a proper truncated object that can now be written to a file if needed.

Arguments
  • obj - The Object that will be truncated.
  • maxDepth - (optional) The depth at which to stop building the valid json. Defaults to 10.
  • options - (optional) An option object to customize the behavior of the utility. Defaults to {}.

Current Option Properties

OptionDescription
replaceA string value that is used to replace all truncated values. If this value is not a string then all truncated values will be replaced with undefined

Licence

MIT

Keywords

FAQs

Package last updated on 11 Jan 2017

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