Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3f9210c
Remove Unused Variable
0verk1ll Jul 15, 2019
90bbae0
Improved JSLint Compliance
0verk1ll Jul 15, 2019
39c21f9
Beautify gunzip.js
0verk1ll Jul 15, 2019
1bffd14
Merge pull request #1 from 0verk1ll/develop
0verk1ll Jul 15, 2019
9a3d05b
Improve JSLint Compliance for gunzip.js
0verk1ll Jul 15, 2019
7ddf4af
Merge pull request #2 from 0verk1ll/develop
0verk1ll Jul 15, 2019
85ea874
Improved PyLint Compliance in runner.py
0verk1ll Jul 15, 2019
0cdbbf9
Improve PyLint Compliance for helpers.py
0verk1ll Jul 15, 2019
b298b05
Improved PyLint and PEP8 Compliance
0verk1ll Jul 15, 2019
d534d73
Improved PEP8 Compliance
0verk1ll Jul 15, 2019
5a8f637
Improve PEP8 Compliance
0verk1ll Jul 15, 2019
afd1983
Improved PEP8 Whitespace Compliance
0verk1ll Jul 15, 2019
244bd11
Add Parens to `print` and Improve PEP8 Compliance
0verk1ll Jul 15, 2019
d28abe4
Merge pull request #3 from 0verk1ll/develop
0verk1ll Jul 15, 2019
2539fcf
Replaced Tabs with Spaces
0verk1ll Jul 15, 2019
5b320ec
Add renovate.json
renovate-bot Jul 15, 2019
d795ec7
Merge pull request #4 from 0verk1ll/renovate/configure
0verk1ll Jul 15, 2019
fb92383
Pin dependency optimist to 0.2.8
renovate-bot Jul 15, 2019
f569260
Improve PEP8 Compliance
0verk1ll Jul 15, 2019
8b36b55
Merge pull request #6 from 0verk1ll/develop
0verk1ll Jul 15, 2019
3a3d3d0
Merge pull request #5 from 0verk1ll/renovate/pin-dependencies
0verk1ll Jul 15, 2019
6381cc4
Improve JSHint Compliance
0verk1ll Jul 15, 2019
84fe9a7
Merge pull request #8 from 0verk1ll/develop
0verk1ll Jul 15, 2019
9b0dd5d
Update README.md
0verk1ll Jul 15, 2019
1395bf9
Remove Trailing Whitespace
0verk1ll Jul 15, 2019
2312c03
Improve PyLint Compliance
0verk1ll Jul 15, 2019
0c8eefe
Improved PyLint Compliance
0verk1ll Jul 15, 2019
c47f3c5
Remove Spaces Between `print` and `(`
0verk1ll Jul 15, 2019
fce27de
Merge pull request #9 from 0verk1ll/develop
0verk1ll Jul 15, 2019
903cde5
Improve Linter Compliance
Jul 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
Intro
=====
## Intro

*gzip-js* is a pure JavaScript implementation of the GZIP file format. It uses the DEFLATE algorithm for compressing data.

Please note that since this is a pure JavaScript implementation, it should NOT be used on the server for production code. It also does not comply 100% with the standard, yet.

The main goal of this project is to bring GZIP compression to the browser.

API
===
## API

There is only one function so far, zip:

function zip(data[, options])

* data- String of text or byte array to compress
* options- object with options; options include:
* level- compression level (1-9); default 6
Expand All @@ -23,11 +21,11 @@ function zip(data[, options])
Sample usage:

var gzip = require('gzip-js'),
options = {
level: 3,
name: 'hello-world.txt',
timestamp: parseInt(Date.now() / 1000, 10)
};

// out will be a JavaScript Array of bytes
var out = gzip.zip('Hello world', options);
options = {
level: 3,
name: 'hello-world.txt',
timestamp: parseInt(Date.now() / 1000, 10)
};

// out will be a JavaScript Array of bytes
var out = gzip.zip('Hello world', options);
40 changes: 20 additions & 20 deletions bin/gunzip.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#!/usr/bin/env node

(function () {
'use strict';
"use strict";

var fs = require('fs'),
optimist = require('optimist'),
gzip = require('../lib/gzip.js'),
argv,
level,
stat,
out;
var fs = require("fs");
var optimist = require("optimist");
var gzip = require("../lib/gzip.js");
var argv;
var stat;
var out;

argv = optimist.usage('Usage: $0 --file [filename] --output [filename]')
.alias({
'f': 'file',
'o': 'output'
})
.demand(['file']).argv;
argv = optimist.usage("Usage: $0 --file [filename] --output [filename]")
.alias({
"f": "file",
"o": "output"
})
.demand(["file"]).argv;

stat = fs.statSync(argv.file);
out = gzip.unzip(fs.readFileSync(argv.file), {
name: argv.file,
timestamp: parseInt(Math.round(stat.mtime.getTime() / 1000))
});
stat = fs.statSync(argv.file);
out = gzip.unzip(fs.readFileSync(argv.file), {
name: argv.file,
timestamp: parseInt(Math.round(stat.mtime.getTime() / 1000))
});

fs.writeFileSync(argv.output || argv.file.replace(/\.gz$/, ''), new Buffer(out));
fs.writeFileSync(argv.output || argv.file.replace(/\.gz$/, ""), new Buffer(out));
}());
43 changes: 20 additions & 23 deletions bin/gzip.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
#!/usr/bin/env node

(function () {
'use strict';
"use strict";

var fs = require('fs'),
optimist = require('optimist'),
gzip = require('../lib/gzip.js'),
argv,
level,
stat,
out;
var fs = require("fs");
var optimist = require("optimist");
var gzip = require("../lib/gzip.js");
var argv;
var stat;
var out;

argv = optimist.usage('Usage: $0 --level [1-9] --file [filename] --output [filename]')
.alias({
'f': 'file',
'o': 'output',
'l': 'level'
})
.default('level', gzip.DEFAULT_LEVEL)
.demand(['file']).argv;
argv = optimist.usage("Usage: $0 --file [filename] --output [filename]")
.alias({
"f": "file",
"o": "output"
})
.demand(["file"]).argv;

stat = fs.statSync(argv.file);
out = gzip.zip(fs.readFileSync(argv.file), {
name: argv.file,
level: argv.level,
timestamp: parseInt(Math.round(stat.mtime.getTime() / 1000))
});
stat = fs.statSync(argv.file);
out = gzip.unzip(fs.readFileSync(argv.file), {
name: argv.file,
timestamp: parseInt(Math.round(stat.mtime.getTime() / 1000))
});

fs.writeFileSync(argv.output || argv.file + '.gz', new Buffer(out));
fs.writeFileSync(argv.output || argv.file.replace(/\.gz$/, ""), new Buffer(out));
}());
Loading