Skip to content

Commit

Permalink
Update version 1.0.0
Browse files Browse the repository at this point in the history
Change getJSONFromLZWString and getLZWStringFromJSON to pack and unpack
  • Loading branch information
tcorral committed Oct 28, 2013
1 parent bd73b72 commit 522ae45
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 24 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
JSONC
=====
# Update to version 0.3.0
# Update to version 1.0.0

[![Build Status](https://travis-ci.org/tcorral/JSONC.png)](https://travis-ci.org/tcorral/JSONC)

Expand All @@ -19,9 +19,9 @@ JSONC has two differents approaches to reduce the size of the amount of data to
* Be careful with this method because it's really impressive if you use it with a JSON with a big amount of data, but it
could be awful if you use it to compress JSON objects with small amount of data because it could increase the final size.
* The rate compression could variate from 7.5% to 32.81% depending of the type and values of data.
* *JSONC.getLZWStringFromJSON* - Compress JSON objects using LZW compression algorithm, to make the job JSONC uses the
* *JSONC.pack* - Compress JSON objects using LZW compression algorithm, to make the job JSONC uses the
lz-string library from @pieroxy - https://github.com/pieroxy/lz-string/
* You can use getLZWStringFromJSON to compress any JSON objects even if these objects are not been compressed using JSONC
* You can use pack to compress any JSON objects even if these objects are not been compressed using JSONC
See Usage for more details.

##Usage
Expand All @@ -39,22 +39,22 @@ See Usage for more details.
####Compress a normal JSON object as a LZW string:

// Returns the LZW representation as string of the JSON object.
var lzwString = JSONC.getLZWStringFromJSON( json );
var lzwString = JSONC.pack( json );

####Compress a JSON object as a LZW string after compress it using JSONC:

// Returns the LZW representation as string of the JSON object.
var lzwString = JSONC.getLZWStringFromJSON( json, true );
var lzwString = JSONC.pack( json, true );

####Decompress a normal JSON object from a LZW string:

// Returns the original JSON object.
var json = JSONC.getJSONFromLZWString( lzwString );
var json = JSONC.unpack( lzwString );

####Decompress a JSON compressed object using JSONC from a LZW string:

// Returns the original JSON object.
var json = JSONC.getJSONFromLZWString( lzwString, true );
var json = JSONC.unpack( lzwString, true );

## Examples of compression

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsoncomp",
"version": "0.3.0",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "git:https://github.com/tcorral/JSONC.git"
Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
1.0.0
Change the API name of getJSONFromLZWString and getLZWStringFromJSON to pack and unpack that are more readable.
0.3.0
Add new methods to allow the user to compress JSON objects using LZW even if the objects are not been compressed using
JSONC.compress.
Expand Down
4 changes: 2 additions & 2 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ <h2>Decompress command</h2>
<script type="text/javascript" src="data/data2.js"></script>
<script type="text/javascript" src="../vendor/lz-string-1.0.2.js"></script>
<script type="text/javascript">
var json_cc = JSONC.getLZWStringFromJSON( obj, true );
var unjson_cc = JSONC.getJSONFromLZWString( json_cc );
var json_cc = JSONC.pack( obj, true );
var unjson_cc = JSONC.unpack( json_cc );
var json_c = JSONC.compress( obj );
var json_unc = JSONC.decompress( json_c );
var json_c2 = JSONC.compress( obj2 );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsoncomp",
"version": "0.3.0",
"version": "1.0.0",
"description": "Compress your JSON to send and get a lot of data to/from server",
"homepage": "http:https://tcorral.github.com/JSONC/",
"author": "Tomas Corral",
Expand Down
4 changes: 2 additions & 2 deletions src/JSONC.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
* @param bCompress
* @returns {String}
*/
JSONC.getLZWStringFromJSON = function( json, bCompress )
JSONC.pack = function( json, bCompress )
{
var str = JSON.stringify( (bCompress ? JSONC.compress( json ): json) );
return LZString.compress( str );
Expand Down Expand Up @@ -325,7 +325,7 @@
* @param bDecompress
* @returns {Object}
*/
JSONC.getJSONFromLZWString = function ( lzw, bDecompress )
JSONC.unpack = function ( lzw, bDecompress )
{
var str = LZString.decompress( lzw ),
json = JSON.parse( str );
Expand Down
12 changes: 6 additions & 6 deletions test/JSONC.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ describe('JSONC.decompress', function (){

expect(retrieved).toEqual(expected);
});
describe('JSONC.getLZWStringFromJSON', function(){
describe('JSONC.pack', function(){
it('should test that returns the expected string', function(){
var retrieved,
obj = {
Expand All @@ -266,7 +266,7 @@ describe('JSONC.decompress', function (){
},
expected = "㞂…ࡠ⸒׀浑䂦ٲ밈쀚ኣ™ʠᦞਅ申耖㌞⸁壘쪸͡ꀗ䚐";

retrieved = JSONC.getLZWStringFromJSON( obj );
retrieved = JSONC.pack( obj );

expect(retrieved).toEqual(expected);
});
Expand All @@ -288,12 +288,12 @@ describe('JSONC.decompress', function (){
},
expected = "㞂•⁜ඪࠥȰڄȒ肙偡⠙聟既耖吴聖岠ඐ腵借䩓℀ᜁ䰆盢ኔḃ멦ሏ᜾菱䢅쀉聃溪䈔␀";

retrieved = JSONC.getLZWStringFromJSON( obj, true );
retrieved = JSONC.pack( obj, true );

expect(retrieved).toEqual(expected);
});
});
describe('JSONC.getJSONFromLZWString', function(){
describe('JSONC.unpack', function(){
it('should test that returns the expected object', function(){
var retrieved,
obj = {
Expand All @@ -312,7 +312,7 @@ describe('JSONC.decompress', function (){
},
lzw = "㞂…ࡠ⸒׀浑䂦ٲ밈쀚ኣ™ʠᦞਅ申耖㌞⸁壘쪸͡ꀗ䚐";

retrieved = JSONC.getJSONFromLZWString( lzw );
retrieved = JSONC.unpack( lzw );

expect(retrieved).toEqual(obj);
});
Expand All @@ -334,7 +334,7 @@ describe('JSONC.decompress', function (){
},
lzw = "㞂•⁜ඪࠥȰڄȒ肙偡⠙聟既耖吴聖岠ඐ腵借䩓℀ᜁ䰆盢ኔḃ멦ሏ᜾菱䢅쀉聃溪䈔␀";

retrieved = JSONC.getJSONFromLZWString( lzw, true );
retrieved = JSONC.unpack( lzw, true );

expect(retrieved).toEqual(obj);
});
Expand Down
4 changes: 2 additions & 2 deletions versions/jsonc.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ var LZString = {
* @param bCompress
* @returns {String}
*/
JSONC.getLZWStringFromJSON = function( json, bCompress )
JSONC.pack = function( json, bCompress )
{
var str = JSON.stringify( (bCompress ? JSONC.compress( json ): json) );
return LZString.compress( str );
Expand Down Expand Up @@ -528,7 +528,7 @@ var LZString = {
* @param bDecompress
* @returns {Object}
*/
JSONC.getJSONFromLZWString = function ( lzw, bDecompress )
JSONC.unpack = function ( lzw, bDecompress )
{
var str = LZString.decompress( lzw ),
json = JSON.parse( str );
Expand Down
4 changes: 2 additions & 2 deletions versions/jsonc.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified versions/jsonc.min.js.gz
Binary file not shown.
Loading

0 comments on commit 522ae45

Please sign in to comment.