npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-json-minify

v1.1.0

Published

JSON minification plugin without concatination.

Downloads

8,740

Readme

grunt-json-minify

Build Status

Grunt JSON minification task that does not concatinate the output. For concatination use grunt-minjson.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-json-minify

Then add this line to your project's Gruntfile.js gruntfile:

grunt.loadNpmTasks('grunt-json-minify');

Usage

Set the files parameter to the directory you want to minify. The minification is inplace, so you want to copy the data to the destination before you minify.

Example:

'json-minify': {
  build: {
    files: 'build/**/*.json'
  }
}

Options

  • encoding(Default undefined) The encoding that should be used for reading and writing the json files.
  • skipOnError (Default false) Ignore files that produce a parse error while minification.

Internally this plugin uses the JSON.stringify and JSON.parse method for minification. You can configure this process by the following parameters:

  • reviver (Default undefined) If a function, prescribes how the value originally produced by parsing is transformed, before being returned.
  • replacer (Default undefined) A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string.
  • space (Default '') A String or Number object that's used to insert white space into the output JSON string for readability purposes. If this is a Number, it indicates the number of space characters to use as white space; this number is capped at 10 if it's larger than that. Values less than 1 indicate that no space should be used. If this is a String, the string (or the first 10 characters of the string, if it's longer than that) is used as white space. If this parameter is not provided (or is null), no white space is used.

For more informations see the JSON.parse and JSON.stringify documentation.

If you want to use your own minification algorithm you can overwrite the default behaviour by using the transform options:

'json-minify': {
  options: {
    transform: function (data, options) {
      return JSON5.stringify(JSON5.parse(data));
    }
  },
  build: {
    files: 'build/**/*.json'
  }
}

This example reconstructs the previous behavior before version 1.0.0. The data attribute is the json file content and the options are the current task options.

License

Copyright (c) 2016 werk85 Licensed under the MIT license.