mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-08-25 19:08:07 +01:00
Coding Style & eslint rules update
This commit is contained in:
parent
7385ffd8da
commit
500bc5d042
26 changed files with 549 additions and 528 deletions
118
.eslintrc
118
.eslintrc
|
@ -1,118 +0,0 @@
|
||||||
env:
|
|
||||||
node: true
|
|
||||||
browser: false
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
- nodeca
|
|
||||||
|
|
||||||
rules:
|
|
||||||
# block-scoped-var: 2
|
|
||||||
# brace-style: [ 2, '1tbs', { allowSingleLine: true } ]
|
|
||||||
# comma-spacing: 2
|
|
||||||
comma-style: 2
|
|
||||||
consistent-this: [ 2, self ]
|
|
||||||
consistent-return: 2
|
|
||||||
curly: 2
|
|
||||||
# default-case: 2
|
|
||||||
dot-notation: 2
|
|
||||||
eol-last: 2
|
|
||||||
eqeqeq: 2
|
|
||||||
# guard-for-in: 2
|
|
||||||
handle-callback-err: 2
|
|
||||||
# max-depth: [ 1, 6 ]
|
|
||||||
max-nested-callbacks: [ 1, 4 ]
|
|
||||||
# string can exceed 80 chars, but should not overflow github website :)
|
|
||||||
# max-len: [ 2, 120, 1000 ]
|
|
||||||
# new-cap: 2
|
|
||||||
new-parens: 2
|
|
||||||
no-alert: 2
|
|
||||||
no-array-constructor: 2
|
|
||||||
# no-bitwise: 2
|
|
||||||
no-caller: 2
|
|
||||||
no-catch-shadow: 2
|
|
||||||
no-comma-dangle: 2
|
|
||||||
no-cond-assign: 2
|
|
||||||
# no-console: 1
|
|
||||||
no-constant-condition: 2
|
|
||||||
no-control-regex: 2
|
|
||||||
no-debugger: 2
|
|
||||||
no-delete-var: 2
|
|
||||||
no-dupe-keys: 2
|
|
||||||
no-div-regex: 2
|
|
||||||
# no-empty: 2
|
|
||||||
no-empty-class: 2
|
|
||||||
no-empty-label: 2
|
|
||||||
no-else-return: 2
|
|
||||||
no-eq-null: 2
|
|
||||||
no-ex-assign: 2
|
|
||||||
no-extend-native: 2
|
|
||||||
no-extra-bind: 2
|
|
||||||
no-extra-boolean-cast: 2
|
|
||||||
no-extra-semi: 2
|
|
||||||
no-extra-strict: 2
|
|
||||||
no-eval: 2
|
|
||||||
no-floating-decimal: 2
|
|
||||||
no-func-assign: 2
|
|
||||||
no-implied-eval: 2
|
|
||||||
no-inner-declarations: 2
|
|
||||||
no-invalid-regexp: 2
|
|
||||||
no-irregular-whitespace: 2
|
|
||||||
no-label-var: 2
|
|
||||||
# no-labels: 2
|
|
||||||
no-lone-blocks: 2
|
|
||||||
no-lonely-if: 2
|
|
||||||
no-loop-func: 2
|
|
||||||
no-mixed-requires: 2
|
|
||||||
no-mixed-spaces-and-tabs: 2
|
|
||||||
no-multi-str: 2
|
|
||||||
no-native-reassign: 2
|
|
||||||
no-negated-in-lhs: 2
|
|
||||||
no-new: 2
|
|
||||||
no-new-func: 2
|
|
||||||
no-new-object: 2
|
|
||||||
no-new-require: 2
|
|
||||||
no-new-wrappers: 2
|
|
||||||
no-obj-calls: 2
|
|
||||||
no-octal: 2
|
|
||||||
no-octal-escape: 2
|
|
||||||
no-path-concat: 2
|
|
||||||
no-redeclare: 2
|
|
||||||
no-regex-spaces: 2
|
|
||||||
no-reserved-keys: 2
|
|
||||||
no-return-assign: 2
|
|
||||||
no-script-url: 2
|
|
||||||
no-sequences: 2
|
|
||||||
no-shadow: 2
|
|
||||||
no-shadow-restricted-names: 2
|
|
||||||
# no-space-before-semi: 2
|
|
||||||
no-sparse-arrays: 2
|
|
||||||
no-trailing-spaces: 2
|
|
||||||
no-undef: 2
|
|
||||||
no-undef-init: 2
|
|
||||||
no-undefined: 2
|
|
||||||
no-unreachable: 2
|
|
||||||
no-unused-expressions: 2
|
|
||||||
no-unused-vars: 2
|
|
||||||
no-use-before-define: 2
|
|
||||||
no-with: 2
|
|
||||||
no-wrap-func: 2
|
|
||||||
quotes: [ 2, single, avoid-escape ]
|
|
||||||
radix: 2
|
|
||||||
semi: 2
|
|
||||||
space-after-keywords: [ 2, always, , { "checkFunctionKeyword": true } ]
|
|
||||||
space-before-blocks: 2
|
|
||||||
# space-in-brackets: [ 2, always, { propertyName: false } ]
|
|
||||||
space-in-parens: [ 2, never ]
|
|
||||||
# space-infix-ops: 2
|
|
||||||
space-return-throw-case: 2
|
|
||||||
space-unary-ops: 2
|
|
||||||
# spaced-line-comment: [ 2, always, { exceptions: [ '/' ] } ]
|
|
||||||
strict: 2
|
|
||||||
use-isnan: 2
|
|
||||||
yoda: 2
|
|
||||||
valid-typeof: 2
|
|
||||||
|
|
||||||
#
|
|
||||||
# Our custom rules
|
|
||||||
#
|
|
||||||
nodeca/indent: [ 2, spaces, 2 ]
|
|
131
.eslintrc.yml
Normal file
131
.eslintrc.yml
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
env:
|
||||||
|
node: true
|
||||||
|
es6: true
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- nodeca
|
||||||
|
|
||||||
|
rules:
|
||||||
|
accessor-pairs: 2
|
||||||
|
array-bracket-spacing: [ 2, "always", { "singleValue": true, "objectsInArrays": true, "arraysInArrays": true } ]
|
||||||
|
block-scoped-var: 2
|
||||||
|
block-spacing: 2
|
||||||
|
#brace-style: [ 2, '1tbs', { "allowSingleLine": true } ]
|
||||||
|
#callback-return: 2
|
||||||
|
comma-dangle: 2
|
||||||
|
comma-spacing: 2
|
||||||
|
comma-style: 2
|
||||||
|
computed-property-spacing: [ 2, never ]
|
||||||
|
#consistent-return: 2
|
||||||
|
consistent-this: [ 2, self ]
|
||||||
|
curly: [ 2, 'multi-line' ]
|
||||||
|
# dot-notation: [ 2, { allowKeywords: true } ]
|
||||||
|
dot-location: [ 2, 'property' ]
|
||||||
|
eol-last: 2
|
||||||
|
eqeqeq: 2
|
||||||
|
func-style: [ 2, declaration ]
|
||||||
|
guard-for-in: 2
|
||||||
|
handle-callback-err: 2
|
||||||
|
#indent: [ 2, 2, { VariableDeclarator: { var: 2, let: 2, const: 3 }, SwitchCase: 1 } ]
|
||||||
|
# key-spacing: [ 2, { "align": "value" } ]
|
||||||
|
keyword-spacing: 2
|
||||||
|
linebreak-style: 2
|
||||||
|
#max-depth: [ 1, 3 ]
|
||||||
|
max-nested-callbacks: [ 1, 7 ]
|
||||||
|
# string can exceed 80 chars, but should not overflow github website :)
|
||||||
|
#max-len: [ 2, 120, 1000 ]
|
||||||
|
new-cap: 2
|
||||||
|
new-parens: 2
|
||||||
|
no-alert: 2
|
||||||
|
no-array-constructor: 2
|
||||||
|
# no-bitwise: 2
|
||||||
|
no-caller: 2
|
||||||
|
no-case-declarations: 2
|
||||||
|
no-catch-shadow: 2
|
||||||
|
no-cond-assign: 2
|
||||||
|
no-console: 1
|
||||||
|
no-constant-condition: 2
|
||||||
|
no-control-regex: 2
|
||||||
|
no-debugger: 1
|
||||||
|
no-delete-var: 2
|
||||||
|
no-div-regex: 2
|
||||||
|
no-dupe-args: 2
|
||||||
|
no-dupe-keys: 2
|
||||||
|
no-duplicate-case: 2
|
||||||
|
no-else-return: 2
|
||||||
|
# no-empty: 1
|
||||||
|
no-empty-character-class: 2
|
||||||
|
no-empty-pattern: 2
|
||||||
|
no-eq-null: 2
|
||||||
|
no-eval: 2
|
||||||
|
no-ex-assign: 2
|
||||||
|
no-extend-native: 2
|
||||||
|
no-extra-bind: 2
|
||||||
|
no-extra-boolean-cast: 2
|
||||||
|
no-extra-semi: 2
|
||||||
|
no-fallthrough: 2
|
||||||
|
no-floating-decimal: 2
|
||||||
|
no-func-assign: 2
|
||||||
|
no-implied-eval: 2
|
||||||
|
no-inner-declarations: 2
|
||||||
|
no-invalid-regexp: 2
|
||||||
|
no-irregular-whitespace: 2
|
||||||
|
no-iterator: 2
|
||||||
|
#no-labels: 2
|
||||||
|
no-label-var: 2
|
||||||
|
no-lone-blocks: 1
|
||||||
|
no-lonely-if: 2
|
||||||
|
no-loop-func: 2
|
||||||
|
no-mixed-requires: [ 1, { "grouping": true } ]
|
||||||
|
no-mixed-spaces-and-tabs: 2
|
||||||
|
no-native-reassign: 2
|
||||||
|
no-negated-in-lhs: 2
|
||||||
|
no-new: 2
|
||||||
|
no-new-func: 2
|
||||||
|
no-new-object: 2
|
||||||
|
no-new-require: 2
|
||||||
|
no-new-wrappers: 2
|
||||||
|
no-obj-calls: 2
|
||||||
|
no-octal: 2
|
||||||
|
no-octal-escape: 2
|
||||||
|
no-path-concat: 2
|
||||||
|
no-proto: 2
|
||||||
|
no-redeclare: 2
|
||||||
|
# no-regex-spaces: 2
|
||||||
|
no-return-assign: 2
|
||||||
|
no-self-compare: 2
|
||||||
|
no-sequences: 2
|
||||||
|
# no-shadow: 2
|
||||||
|
no-shadow-restricted-names: 2
|
||||||
|
no-sparse-arrays: 2
|
||||||
|
no-throw-literal: 2
|
||||||
|
no-trailing-spaces: 2
|
||||||
|
no-undef: 2
|
||||||
|
no-undef-init: 2
|
||||||
|
no-undefined: 2
|
||||||
|
no-unexpected-multiline: 2
|
||||||
|
no-unreachable: 2
|
||||||
|
no-unused-expressions: 2
|
||||||
|
no-unused-vars: 2
|
||||||
|
no-use-before-define: 2
|
||||||
|
no-void: 2
|
||||||
|
no-with: 2
|
||||||
|
object-curly-spacing: [ 2, always, { "objectsInObjects": true, "arraysInObjects": true } ]
|
||||||
|
operator-assignment: 1
|
||||||
|
semi: 2
|
||||||
|
semi-spacing: 2
|
||||||
|
space-before-blocks: 2
|
||||||
|
space-before-function-paren: [ 2, { "anonymous": "always", "named": "never" } ]
|
||||||
|
space-in-parens: [ 2, never ]
|
||||||
|
space-infix-ops: [ 2, { int32Hint: true } ]
|
||||||
|
space-unary-ops: 2
|
||||||
|
#spaced-comment: [ 1, always, { exceptions: [ '/', '=' ] } ]
|
||||||
|
strict: [ 2, global ]
|
||||||
|
quotes: [ 2, single, avoid-escape ]
|
||||||
|
quote-props: [ 1, 'as-needed', { "keywords": true } ]
|
||||||
|
radix: 2
|
||||||
|
use-isnan: 2
|
||||||
|
valid-typeof: 2
|
||||||
|
yoda: [ 2, never, { "exceptRange": true } ]
|
||||||
|
|
||||||
|
nodeca/indent: [2, spaces, 2]
|
22
Makefile
22
Makefile
|
@ -23,24 +23,24 @@ help:
|
||||||
|
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
eslint --reset .
|
./node_modules/.bin/eslint .
|
||||||
|
|
||||||
|
|
||||||
test: lint
|
test: lint
|
||||||
mocha
|
./node_modules/.bin/mocha
|
||||||
|
|
||||||
test-browser: lint
|
test-browser: lint
|
||||||
rm -f ./test/browser/pako.js
|
rm -f ./test/browser/pako.js
|
||||||
browserify -r ./ -s pako > test/browser/pako.js
|
./node_modules/.bin/browserify -r ./ -s pako > test/browser/pako.js
|
||||||
@SAUCE_PROJ=${GITHUB_PROJ} grunt test
|
@SAUCE_PROJ=${GITHUB_PROJ} grunt test
|
||||||
|
|
||||||
cover:
|
cover:
|
||||||
rm -rf cover
|
rm -rf cover
|
||||||
istanbul cover node_modules/.bin/_mocha
|
./node_modules/.bin/istanbul cover node_modules/.bin/_mocha
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
rm -rf ./doc
|
rm -rf ./doc
|
||||||
ndoc --link-format "{package.homepage}/blob/${CURR_HEAD}/{file}#L{line}"
|
./node_modules/.bin/ndoc --link-format "{package.homepage}/blob/${CURR_HEAD}/{file}#L{line}"
|
||||||
|
|
||||||
|
|
||||||
browserify:
|
browserify:
|
||||||
|
@ -48,22 +48,22 @@ browserify:
|
||||||
mkdir dist
|
mkdir dist
|
||||||
# Browserify
|
# Browserify
|
||||||
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
|
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
|
||||||
browserify -r ./ -s pako \
|
./node_modules/.bin/browserify -r ./ -s pako \
|
||||||
) > dist/pako.js
|
) > dist/pako.js
|
||||||
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
|
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
|
||||||
browserify -r ./lib/deflate.js -s pako \
|
./node_modules/.bin/browserify -r ./lib/deflate.js -s pako \
|
||||||
) > dist/pako_deflate.js
|
) > dist/pako_deflate.js
|
||||||
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
|
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
|
||||||
browserify -r ./lib/inflate.js -s pako \
|
./node_modules/.bin/browserify -r ./lib/inflate.js -s pako \
|
||||||
) > dist/pako_inflate.js
|
) > dist/pako_inflate.js
|
||||||
# Minify
|
# Minify
|
||||||
uglifyjs dist/pako.js -c -m \
|
./node_modules/.bin/uglifyjs dist/pako.js -c -m \
|
||||||
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
|
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
|
||||||
> dist/pako.min.js
|
> dist/pako.min.js
|
||||||
uglifyjs dist/pako_deflate.js -c -m \
|
./node_modules/.bin/uglifyjs dist/pako_deflate.js -c -m \
|
||||||
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
|
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
|
||||||
> dist/pako_deflate.min.js
|
> dist/pako_deflate.min.js
|
||||||
uglifyjs dist/pako_inflate.js -c -m \
|
./node_modules/.bin/uglifyjs dist/pako_inflate.js -c -m \
|
||||||
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
|
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
|
||||||
> dist/pako_inflate.min.js
|
> dist/pako_inflate.min.js
|
||||||
# Update bower package
|
# Update bower package
|
||||||
|
|
|
@ -30,6 +30,7 @@ fs.readdirSync(IMPLS_DIRECTORY).sort().forEach(function (name) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
var SAMPLES_DIRECTORY = path.join(__dirname, 'samples');
|
var SAMPLES_DIRECTORY = path.join(__dirname, 'samples');
|
||||||
var SAMPLES = [];
|
var SAMPLES = [];
|
||||||
|
|
|
@ -5,7 +5,7 @@ var zlib_deflate = require('./zlib/deflate.js');
|
||||||
var utils = require('./utils/common');
|
var utils = require('./utils/common');
|
||||||
var strings = require('./utils/strings');
|
var strings = require('./utils/strings');
|
||||||
var msg = require('./zlib/messages');
|
var msg = require('./zlib/messages');
|
||||||
var zstream = require('./zlib/zstream');
|
var ZStream = require('./zlib/zstream');
|
||||||
|
|
||||||
var toString = Object.prototype.toString;
|
var toString = Object.prototype.toString;
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ var Z_DEFLATED = 8;
|
||||||
* console.log(deflate.result);
|
* console.log(deflate.result);
|
||||||
* ```
|
* ```
|
||||||
**/
|
**/
|
||||||
var Deflate = function(options) {
|
function Deflate(options) {
|
||||||
|
|
||||||
this.options = utils.assign({
|
this.options = utils.assign({
|
||||||
level: Z_DEFAULT_COMPRESSION,
|
level: Z_DEFAULT_COMPRESSION,
|
||||||
|
@ -143,7 +143,7 @@ var Deflate = function(options) {
|
||||||
this.ended = false; // used to avoid multiple onEnd() calls
|
this.ended = false; // used to avoid multiple onEnd() calls
|
||||||
this.chunks = []; // chunks of compressed data
|
this.chunks = []; // chunks of compressed data
|
||||||
|
|
||||||
this.strm = new zstream();
|
this.strm = new ZStream();
|
||||||
this.strm.avail_out = 0;
|
this.strm.avail_out = 0;
|
||||||
|
|
||||||
var status = zlib_deflate.deflateInit2(
|
var status = zlib_deflate.deflateInit2(
|
||||||
|
@ -162,7 +162,7 @@ var Deflate = function(options) {
|
||||||
if (opt.header) {
|
if (opt.header) {
|
||||||
zlib_deflate.deflateSetHeader(this.strm, opt.header);
|
zlib_deflate.deflateSetHeader(this.strm, opt.header);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deflate#push(data[, mode]) -> Boolean
|
* Deflate#push(data[, mode]) -> Boolean
|
||||||
|
|
|
@ -6,8 +6,8 @@ var utils = require('./utils/common');
|
||||||
var strings = require('./utils/strings');
|
var strings = require('./utils/strings');
|
||||||
var c = require('./zlib/constants');
|
var c = require('./zlib/constants');
|
||||||
var msg = require('./zlib/messages');
|
var msg = require('./zlib/messages');
|
||||||
var zstream = require('./zlib/zstream');
|
var ZStream = require('./zlib/zstream');
|
||||||
var gzheader = require('./zlib/gzheader');
|
var GZheader = require('./zlib/gzheader');
|
||||||
|
|
||||||
var toString = Object.prototype.toString;
|
var toString = Object.prototype.toString;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ var toString = Object.prototype.toString;
|
||||||
* console.log(inflate.result);
|
* console.log(inflate.result);
|
||||||
* ```
|
* ```
|
||||||
**/
|
**/
|
||||||
var Inflate = function(options) {
|
function Inflate(options) {
|
||||||
|
|
||||||
this.options = utils.assign({
|
this.options = utils.assign({
|
||||||
chunkSize: 16384,
|
chunkSize: 16384,
|
||||||
|
@ -127,7 +127,7 @@ var Inflate = function(options) {
|
||||||
this.ended = false; // used to avoid multiple onEnd() calls
|
this.ended = false; // used to avoid multiple onEnd() calls
|
||||||
this.chunks = []; // chunks of compressed data
|
this.chunks = []; // chunks of compressed data
|
||||||
|
|
||||||
this.strm = new zstream();
|
this.strm = new ZStream();
|
||||||
this.strm.avail_out = 0;
|
this.strm.avail_out = 0;
|
||||||
|
|
||||||
var status = zlib_inflate.inflateInit2(
|
var status = zlib_inflate.inflateInit2(
|
||||||
|
@ -139,10 +139,10 @@ var Inflate = function(options) {
|
||||||
throw new Error(msg[status]);
|
throw new Error(msg[status]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.header = new gzheader();
|
this.header = new GZheader();
|
||||||
|
|
||||||
zlib_inflate.inflateGetHeader(this.strm, this.header);
|
zlib_inflate.inflateGetHeader(this.strm, this.header);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inflate#push(data[, mode]) -> Boolean
|
* Inflate#push(data[, mode]) -> Boolean
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
/* Allowed flush values; see deflate() and inflate() below for details */
|
/* Allowed flush values; see deflate() and inflate() below for details */
|
||||||
|
|
|
@ -28,7 +28,7 @@ function crc32(crc, buf, len, pos) {
|
||||||
var t = crcTable,
|
var t = crcTable,
|
||||||
end = pos + len;
|
end = pos + len;
|
||||||
|
|
||||||
crc = crc ^ (-1);
|
crc ^= -1;
|
||||||
|
|
||||||
for (var i = pos; i < end; i++) {
|
for (var i = pos; i < end; i++) {
|
||||||
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
|
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
|
||||||
|
|
|
@ -1017,13 +1017,13 @@ function deflate_huff(s, flush) {
|
||||||
* exclude worst case performance for pathological files. Better values may be
|
* exclude worst case performance for pathological files. Better values may be
|
||||||
* found for specific files.
|
* found for specific files.
|
||||||
*/
|
*/
|
||||||
var Config = function (good_length, max_lazy, nice_length, max_chain, func) {
|
function Config(good_length, max_lazy, nice_length, max_chain, func) {
|
||||||
this.good_length = good_length;
|
this.good_length = good_length;
|
||||||
this.max_lazy = max_lazy;
|
this.max_lazy = max_lazy;
|
||||||
this.nice_length = nice_length;
|
this.nice_length = nice_length;
|
||||||
this.max_chain = max_chain;
|
this.max_chain = max_chain;
|
||||||
this.func = func;
|
this.func = func;
|
||||||
};
|
}
|
||||||
|
|
||||||
var configuration_table;
|
var configuration_table;
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ var MAX_WBITS = 15;
|
||||||
var DEF_WBITS = MAX_WBITS;
|
var DEF_WBITS = MAX_WBITS;
|
||||||
|
|
||||||
|
|
||||||
function ZSWAP32(q) {
|
function zswap32(q) {
|
||||||
return (((q >>> 24) & 0xff) +
|
return (((q >>> 24) & 0xff) +
|
||||||
((q >>> 8) & 0xff00) +
|
((q >>> 8) & 0xff00) +
|
||||||
((q & 0xff00) << 8) +
|
((q & 0xff00) << 8) +
|
||||||
|
@ -711,7 +711,7 @@ function inflate(strm, flush) {
|
||||||
state.head.hcrc = ((state.flags >> 9) & 1);
|
state.head.hcrc = ((state.flags >> 9) & 1);
|
||||||
state.head.done = true;
|
state.head.done = true;
|
||||||
}
|
}
|
||||||
strm.adler = state.check = 0 /*crc32(0L, Z_NULL, 0)*/;
|
strm.adler = state.check = 0;
|
||||||
state.mode = TYPE;
|
state.mode = TYPE;
|
||||||
break;
|
break;
|
||||||
case DICTID:
|
case DICTID:
|
||||||
|
@ -723,7 +723,7 @@ function inflate(strm, flush) {
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
//===//
|
//===//
|
||||||
strm.adler = state.check = ZSWAP32(hold);
|
strm.adler = state.check = zswap32(hold);
|
||||||
//=== INITBITS();
|
//=== INITBITS();
|
||||||
hold = 0;
|
hold = 0;
|
||||||
bits = 0;
|
bits = 0;
|
||||||
|
@ -1357,8 +1357,8 @@ function inflate(strm, flush) {
|
||||||
|
|
||||||
}
|
}
|
||||||
_out = left;
|
_out = left;
|
||||||
// NB: crc32 stored as signed 32-bit int, ZSWAP32 returns signed too
|
// NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
|
||||||
if ((state.flags ? hold : ZSWAP32(hold)) !== state.check) {
|
if ((state.flags ? hold : zswap32(hold)) !== state.check) {
|
||||||
strm.msg = 'incorrect data check';
|
strm.msg = 'incorrect data check';
|
||||||
state.mode = BAD;
|
state.mode = BAD;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'2': 'need dictionary', /* Z_NEED_DICT 2 */
|
2: 'need dictionary', /* Z_NEED_DICT 2 */
|
||||||
'1': 'stream end', /* Z_STREAM_END 1 */
|
1: 'stream end', /* Z_STREAM_END 1 */
|
||||||
'0': '', /* Z_OK 0 */
|
0: '', /* Z_OK 0 */
|
||||||
'-1': 'file error', /* Z_ERRNO (-1) */
|
'-1': 'file error', /* Z_ERRNO (-1) */
|
||||||
'-2': 'stream error', /* Z_STREAM_ERROR (-2) */
|
'-2': 'stream error', /* Z_STREAM_ERROR (-2) */
|
||||||
'-3': 'data error', /* Z_DATA_ERROR (-3) */
|
'-3': 'data error', /* Z_DATA_ERROR (-3) */
|
||||||
|
|
|
@ -84,6 +84,7 @@ var REPZ_3_10 = 17;
|
||||||
var REPZ_11_138 = 18;
|
var REPZ_11_138 = 18;
|
||||||
/* repeat a zero length 11-138 times (7 bits of repeat count) */
|
/* repeat a zero length 11-138 times (7 bits of repeat count) */
|
||||||
|
|
||||||
|
/* eslint-disable comma-spacing,array-bracket-spacing */
|
||||||
var extra_lbits = /* extra bits for each length code */
|
var extra_lbits = /* extra bits for each length code */
|
||||||
[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];
|
[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];
|
||||||
|
|
||||||
|
@ -95,6 +96,8 @@ var extra_blbits = /* extra bits for each bit length code */
|
||||||
|
|
||||||
var bl_order =
|
var bl_order =
|
||||||
[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
|
[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
|
||||||
|
/* eslint-enable comma-spacing,array-bracket-spacing */
|
||||||
|
|
||||||
/* The lengths of the bit length codes are sent in order of decreasing
|
/* The lengths of the bit length codes are sent in order of decreasing
|
||||||
* probability, to avoid transmitting the lengths for unused bit length codes.
|
* probability, to avoid transmitting the lengths for unused bit length codes.
|
||||||
*/
|
*/
|
||||||
|
@ -142,7 +145,7 @@ zero(base_dist);
|
||||||
/* First normalized distance for each code (0 = distance of 1) */
|
/* First normalized distance for each code (0 = distance of 1) */
|
||||||
|
|
||||||
|
|
||||||
var StaticTreeDesc = function (static_tree, extra_bits, extra_base, elems, max_length) {
|
function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
|
||||||
|
|
||||||
this.static_tree = static_tree; /* static tree or NULL */
|
this.static_tree = static_tree; /* static tree or NULL */
|
||||||
this.extra_bits = extra_bits; /* extra bits for each code or NULL */
|
this.extra_bits = extra_bits; /* extra bits for each code or NULL */
|
||||||
|
@ -152,7 +155,7 @@ var StaticTreeDesc = function (static_tree, extra_bits, extra_base, elems, max_l
|
||||||
|
|
||||||
// show if `static_tree` has data or dummy - needed for monomorphic objects
|
// show if `static_tree` has data or dummy - needed for monomorphic objects
|
||||||
this.has_stree = static_tree && static_tree.length;
|
this.has_stree = static_tree && static_tree.length;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
var static_l_desc;
|
var static_l_desc;
|
||||||
|
@ -160,11 +163,11 @@ var static_d_desc;
|
||||||
var static_bl_desc;
|
var static_bl_desc;
|
||||||
|
|
||||||
|
|
||||||
var TreeDesc = function(dyn_tree, stat_desc) {
|
function TreeDesc(dyn_tree, stat_desc) {
|
||||||
this.dyn_tree = dyn_tree; /* the dynamic tree */
|
this.dyn_tree = dyn_tree; /* the dynamic tree */
|
||||||
this.max_code = 0; /* largest code with non zero frequency */
|
this.max_code = 0; /* largest code with non zero frequency */
|
||||||
this.stat_desc = stat_desc; /* the corresponding static tree */
|
this.stat_desc = stat_desc; /* the corresponding static tree */
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
26
package.json
26
package.json
|
@ -2,31 +2,31 @@
|
||||||
"name": "pako",
|
"name": "pako",
|
||||||
"description": "zlib port to javascript - fast, modularized, with browser support",
|
"description": "zlib port to javascript - fast, modularized, with browser support",
|
||||||
"version": "0.2.8",
|
"version": "0.2.8",
|
||||||
"keywords" : [ "zlib", "deflate", "inflate", "gzip" ],
|
"keywords": [
|
||||||
|
"zlib",
|
||||||
|
"deflate",
|
||||||
|
"inflate",
|
||||||
|
"gzip"
|
||||||
|
],
|
||||||
"homepage": "https://github.com/nodeca/pako",
|
"homepage": "https://github.com/nodeca/pako",
|
||||||
|
"contributors": [
|
||||||
"contributors" : [ "Andrei Tuputcyn (https://github.com/andr83)",
|
"Andrei Tuputcyn (https://github.com/andr83)",
|
||||||
"Vitaly Puzrin (https://github.com/puzrin)" ],
|
"Vitaly Puzrin (https://github.com/puzrin)"
|
||||||
|
],
|
||||||
"bugs" : { "url": "https://github.com/nodeca/pako/issues" },
|
"license": "MIT",
|
||||||
"license" : { "type": "MIT", "url": "https://github.com/nodeca/pako/blob/master/LICENSE" },
|
"repository": "nodeca/pako",
|
||||||
"repository" : { "type": "git", "url": "git://github.com/nodeca/pako.git" },
|
|
||||||
|
|
||||||
"main" : "./index.js",
|
|
||||||
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "1.21.5",
|
"mocha": "1.21.5",
|
||||||
"benchmark": "*",
|
"benchmark": "*",
|
||||||
"ansi": "*",
|
"ansi": "*",
|
||||||
"browserify": "*",
|
"browserify": "*",
|
||||||
"eslint": "0.17.1",
|
"eslint": "^2.1.0",
|
||||||
"eslint-plugin-nodeca": "~1.0.3",
|
"eslint-plugin-nodeca": "~1.0.3",
|
||||||
"uglify-js": "*",
|
"uglify-js": "*",
|
||||||
"istanbul": "*",
|
"istanbul": "*",
|
||||||
"ndoc": "*",
|
"ndoc": "*",
|
||||||
"lodash": "*",
|
"lodash": "*",
|
||||||
"async": "*",
|
"async": "*",
|
||||||
|
|
||||||
"grunt": "~0.4.4",
|
"grunt": "~0.4.4",
|
||||||
"grunt-cli": "~0.1.13",
|
"grunt-cli": "~0.1.13",
|
||||||
"grunt-saucelabs": "~8.6.0",
|
"grunt-saucelabs": "~8.6.0",
|
||||||
|
|
|
@ -13,7 +13,7 @@ var path = require('path');
|
||||||
var c = require('../lib/zlib/constants');
|
var c = require('../lib/zlib/constants');
|
||||||
var msg = require('../lib/zlib/messages');
|
var msg = require('../lib/zlib/messages');
|
||||||
var zlib_deflate = require('../lib/zlib/deflate.js');
|
var zlib_deflate = require('../lib/zlib/deflate.js');
|
||||||
var zstream = require('../lib/zlib/zstream');
|
var ZStream = require('../lib/zlib/zstream');
|
||||||
|
|
||||||
var pako = require('../index');
|
var pako = require('../index');
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ describe('Deflate states', function() {
|
||||||
ret = zlib_deflate.deflate(null, 0);
|
ret = zlib_deflate.deflate(null, 0);
|
||||||
assert(ret === c.Z_STREAM_ERROR);
|
assert(ret === c.Z_STREAM_ERROR);
|
||||||
|
|
||||||
strm = new zstream();
|
strm = new ZStream();
|
||||||
|
|
||||||
ret = zlib_deflate.deflateInit(null);
|
ret = zlib_deflate.deflateInit(null);
|
||||||
assert(ret === c.Z_STREAM_ERROR);
|
assert(ret === c.Z_STREAM_ERROR);
|
||||||
|
|
|
@ -136,6 +136,7 @@ function testInflate(samples, inflateOptions, deflateOptions, callback) {
|
||||||
// inflate options have windowBits = 0 to force autodetect window size
|
// inflate options have windowBits = 0 to force autodetect window size
|
||||||
//
|
//
|
||||||
for (name in samples) {
|
for (name in samples) {
|
||||||
|
if (!samples.hasOwnProperty(name)) continue;
|
||||||
data = samples[name];
|
data = samples[name];
|
||||||
|
|
||||||
// always use the same data type to generate sample
|
// always use the same data type to generate sample
|
||||||
|
|
Loading…
Add table
Reference in a new issue