🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More →
Socket
Book a DemoSign in
Socket

json_prune

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json_prune

JSON.prune is a pruning JSON.stringify for the very specific cases where you need to stringify big or recursive javascript objects and don't really need the result to be complete.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

JSON.prune

JSON.prune is a pruning JSON.stringify for the very specific cases where you need to stringify big or recursive javascript objects and don't really need the result to be complete.

JSON.prune also lets you, in case of need, stringify inherited and/or non enumerable properties.

JSON.prune(window.location, {inheritedProperties:true}); // without inherited properties, FireFox and IE only show an empty object

It's totally useless for at least 99% of js developpers.

JSON.prune.log is a proxy over console.log deep cloning the objects (using JSON.prune) before logging them, in order to avoid the delay problem encountered on non primitive objects logging.

You should not use it frequently, only when you really need to see the objects how they were at logging time.

// make sure someObject is logged as it was at logging time
JSON.prune.log(someObject);

NodeJs usage

Install with npm

npm install json_prune

Use it in node as standard module

var JSONPrune = require('json_prune').prune
...
var prunedObj = JSONPrune(objectToPrune)

Window (browser) usage

Include it

<script src=http://dystroy.org/JSON.prune/.js></script>

Use it with

var json = JSON.stringify(window); // fails
var json = JSON.prune(window); // builds a JSON valid string from a pruned version of the
                               // recursive, deep, and not totally accessible window object
var prunedWindow = JSON.parse(JSON.prune(window)); // builds a lighter acyclic version of window

Project/Test page

dystroy.org/JSON.prune

License

Public Domain. Use as you wish and at your own risk.

FAQs

Package last updated on 17 Mar 2015

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