GithubHelp home page GithubHelp logo

json-crunch's Introduction

JSON Crunch

Provides methods for removing whitespace from JSON files to save space.

Installation

You can install JSON Crunch using npm:

npm install json-crunch

or

npm install --save-dev json-crunch

Usage

JSON Crunch has two methods: crunch and crunchToFile

  • jsonCrunch.crunch(filename, encoding="utf8") - Crunches contents of specified file and returns it in string form. (Returns a promise)
  • jsonCrunch.crunchToFile(sourceFile, destFile, encoding="utf8", stats=false) - Crunches contents of file and writes result to another file. (Returns a promise)
    • If stats is true, an object is returned of the form { input: Number, output: Number, percent: Number, saved: Number };
      • input - size of input file
      • output - size of crunched file
      • percent - percentage of original used for crunched
      • saved - percent smaller crunched is from original

Example

const jc = require('json-crunch');

jc.crunchToFile("./source.json", "./source.min.json", "utf8").then(() = > {
	console.log("Successfully crunched file");
}).catch((e) => {
	console.log("Error occured: " e);
});

License

Released under MIT license

json-crunch's People

Contributors

venturewade avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.