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

jsoncompress

v0.1.3

Published

A Node.js and browser JSON compression tool that uses JSON templates (inspired by https://github.com/Raveler/packetflattener), LZ, and optional float decimal reduction to compress JSON data for storage or sending over a network.

Downloads

20

Readme

Build Status

node-jsoncompress

A Node.js and browser JSON compression tool that uses JSON templates (inspired by https://github.com/Raveler/packetflattener), LZ, and optional float decimal reduction to compress JSON data for storage or sending over a network.

Why this module

I needed a really simple way to compress JSON data that was to be sent via WebSockets to reduce the network traffic of an application that I was working on. I also needed to be able to share the code in the browser as on the server.

Goal for this module

The module is supposed to be plug and play, while the compression techniques inside this module hopefully will be changed to get better and smarter, the goal is that the API for the jsoncompress object/module will change as little as possible.

Installation for Node.js

$ cd /my/project/directory
$ npm install jsoncompress --save

WebSocket example and demo

Start the server with

$ node example/socketserver.js

Visit http://localhost:3000 in your browser and open up the console to see the output.

Example for Node.js

'use strict';

var jsoncompress = require('jsoncompress');

var data = { position: { x: 123.3432123, y: 3.2342233, z: 643.3423423 } };
var template = { position: { x: 0, y: 0, z: 0 } };

var compressed = jsoncompress.compress(data, template);
console.log('Compressed string', compressed);

var decompressed = jsoncompress.decompress(compressed, template);
console.log('Decompressed and restored data', decompressed);

Example for browser

The only file that is needed in the browser is browser/jsoncompress.min.js, if you make any changes to the other files, remember to run Grunt to generate a new version of this file. Once the script is imported the global "jsoncompress" is avaliable.

<script src="/path/to/jsoncompress/browser/jsoncompress.min.js"></script>
<script>
    'use strict';

    var jsoncompress = require('jsoncompress');

    var data = { position: { x: 123.3432123, y: 3.2342233, z: 643.3423423 } };
    var template = { position: { x: 0, y: 0, z: 0 } };

    var compressed = jsoncompress.compress(data, template);
    console.log('Compressed string', compressed);

    var decompressed = jsoncompress.decompress(compressed, template);
    console.log('Decompressed and restored data', decompressed);
</script>

Contribute

What is you oppinion of this module? Send you pull requests so we can make this module even better.

License

This project is released under the GPLv3 license.