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

kvm-json

v0.0.4

Published

A JSON compression technique by splitting JSON object into Key, Value and Model

Downloads

4

Readme

kvm-json

A JSON compression technique by splitting JSON object into Key, Value and Model.

npm i kvm-json

Features

  • Compress JSON into KVM model structure
  • Decompress KVM structure into origin JSON object
  • Extra compression using GZIP (can be disabled)
  • Debug mode (turn off compression)

Usage

Import kvm-json into your project

var kvm = require("kvm-json"),
  compress = kvm.compress,
  decompress = kvm.decompress;

Debug mode:

kvm.debugMode(); // or kvm.debugMode(true)

Disable GZIP, will return KVM JSON object:

kvm.disableGzip(); // or kvm.disableGzip(true)

Compression usage:

data = [
  {
    class: "motogp",
    rider: [
      {
        name: "Valentino Rossi",
        age: 39,
        bike_number: 46,
        world_champion: 7
      },
      {
        name: "Marc Márquez",
        age: 25,
        bike_number: 93,
        world_champion: 5
      },
      {
        name: "Jorge Lorenzo",
        age: 31,
        bike_number: 99,
        world_champion: 3
      }
    ]
  },
  {
    class: "moto2",
    rider: [
      {
        name: "Francesco Bagnaia",
        age: 21,
        bike_number: 63,
        world_champion: 1
      },
      {
        name: "Franco Morbidelli",
        age: 24,
        bike_number: 21,
        world_champion: 1
      },
      {
        name: "Pol Espargaró",
        age: 27,
        bike_number: 44,
        world_champion: 1
      }
    ]
  }
];
// original size =>  487 byte

compressed = compress(data);
console.log(compressed);

/**
 * KVM structure result : 
{
  "k": [ "class", "rider", "name", "age", "bike_number", "world_champion" ],
  "v": [ "motogp", "Valentino Rossi", 39, 46, 7, "Marc Márquez", 25, 93, 5, 
         "Jorge Lorenzo", 31, 99, 3, "moto2", "Francesco Bagnaia", 21, 63, 1, 
         "Franco Morbidelli", 24, "Pol Espargaró", 27, 44 ],
  "m": [
    {
      "0": 0,
      "1": [
        {
          "2": 1,
          "3": 2,
          "4": 3,
          "5": 4
        },
        {
          "2": 5,
          "3": 6,
          "4": 7,
          "5": 8
        },
        {
          "2": 9,
          "3": 10,
          "4": 11,
          "5": 12
        }
      ]
    },
    {
      "0": 13,
      "1": [
        {
          "2": 14,
          "3": 15,
          "4": 16,
          "5": 17
        },
        {
          "2": 18,
          "3": 19,
          "4": 15,
          "5": 17
        },
        {
          "2": 20,
          "3": 21,
          "4": 22,
          "5": 17
        }
      ]
    }
  ]
}
kvm size => 442 byte
 
Extra compression using gzip result:

"H4sIAAAAAAAAE1XOwWqEMBAG4FeROc/BxKirx0J7KBVKD70UWaIb3LCasXG3hV32YfoMfYR9sY7
RQksgCfkm/8wFDlC+QdvraQIEb3fG8+n0YPjQ3bw39mC27jQ0gT7J97ttu9fDaMlBjfAxJwx0pG5
kf9W9cUfrKHqhabKASYEqwxyh0r6NqtuXfz+ZM6BMsUgwRXgk35noibxxZ+J6gUWBCYZIyYkPXrv
WTC1Fd7pz2mr+KzBLUKxGUUW+4dH7nvtJhfBMfXQ/jdp32t+++S1HpXjUgUe9QAxljCDCXULJMQm
UEkFByW1TKNUVg6RBsiB5kM0qRRARBxIimJDXemaOF8nffLUUp0txthTna5LYLFosmv5XGS/DiaB
S/mrN6wf+PL6XvAEAAA=="
gzip compressed size => 402 byte

*
*/