New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

json-shrink

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-shrink

shrink json objects with LZMA (7-zip) or Brotli compression + jsonpack

latest
npmnpm
Version
0.0.124
Version published
Weekly downloads
509
-37.32%
Maintainers
1
Weekly downloads
 
Created
Source

json-shrink

shrink objects/json with LZMA (7-zip) or Brotli compression + optional jsonpack

var shrunken = shrink(obj, outputAsString = false, doPack = true, doUseBrotli = false);
var unshrunk = unshrink(shrunken, doUnPack = true, doUseBrotli = false);

Installation

npm i json-shrink

Usage

var jsh = require('json-shrink');
var shrink = jsh.shrink;
var unshrink = jsh.unshrink;

//compressing json into buffer or string:
//shrink(obj, outputAsString = false, doPack = true, doUseBrotli=false)
var original_obj = {ok:"here is some text"};
var compressed_into_buffer = shrink(original_obj); //output as buffer
var compressed_into_string = shrink(original_obj, true); // output as base64 string

//uncompressing
//note - params used for uncompressing must align with the params used for compressing!
//unshrink(shrunken, doUnPack = true, doUseBrotli=false);
console.log("uncompressed str", unshrink(compressed_into_string));
console.log("uncompressed buffer", unshrink(compressed_into_buffer));

//result
//uncompressed str { ok: 'here is some text' }
//uncompressed buffer { ok: 'here is some text' }

Usage - jsonpack disabled

//with jsonpack disabled:
var compressed_buffer_nopack = shrink(original_obj, false, false);
var compressed_string_nopack = shrink(original_obj, true, false);

console.log("uncompressed str - no jsonpack", unshrink(compressed_string_nopack, false));
console.log("uncompressed buffer - no jsonpack", unshrink(compressed_buffer_nopack, false));

//result
//uncompressed str - no jsonpack { ok: 'here is some text' }
//uncompressed buffer - no jsonpack { ok: 'here is some text' }

See Also

  • jsonfile-compressed - uses json-shrink

stonks

Keywords

compression

FAQs

Package last updated on 16 Apr 2022

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