mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-10 22:00:58 +01:00
Replaced jshint with eslint & updated CS
This commit is contained in:
parent
4ace00c10b
commit
cff11fc91b
28 changed files with 184 additions and 141 deletions
7
.eslintignore
Normal file
7
.eslintignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
coverage/
|
||||
demo/
|
||||
dist/
|
||||
node_modules
|
||||
support/demo_template/sample.js
|
||||
benchmark/implementations/
|
||||
test/browser
|
118
.eslintrc
Normal file
118
.eslintrc
Normal file
|
@ -0,0 +1,118 @@
|
|||
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 ]
|
|
@ -1,6 +0,0 @@
|
|||
.git/
|
||||
node_modules/
|
||||
benchmark/implementations
|
||||
coverage/
|
||||
dist/
|
||||
test/browser/pako.js
|
78
.jshintrc
78
.jshintrc
|
@ -1,78 +0,0 @@
|
|||
{
|
||||
// Enforcing Options /////////////////////////////////////////////////////////
|
||||
|
||||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"camelcase" : false, // true: Identifiers must be in camelCase
|
||||
"curly" : true, // Require {} for every new block or scope.
|
||||
"eqeqeq" : true, // Require triple equals i.e. `===`.
|
||||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
|
||||
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||
"indent" : 2, // Specify indentation spacing
|
||||
"latedef" : true, // Prohibit hariable use before definition.
|
||||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||
"noempty" : true, // Prohibit use of empty blocks.
|
||||
"nonew" : true, // Prohibit use of constructors for side-effects.
|
||||
"plusplus" : false, // Prohibit use of `++` & `--`.
|
||||
"quotmark" : "single", // Quotation mark consistency:
|
||||
// false : do nothing (default)
|
||||
// true : ensure whatever is used is consistent
|
||||
// "single" : require single quotes
|
||||
// "double" : require double quotes
|
||||
"undef" : true, // Require all non-global variables be declared before they are used.
|
||||
"unused" : true, // Warns when you define and never use your variables
|
||||
"strict" : true, // Require `use strict` pragma in every file.
|
||||
"trailing" : true, // Prohibit trailing whitespaces.
|
||||
|
||||
// Relaxing Options //////////////////////////////////////////////////////////
|
||||
|
||||
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
|
||||
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
||||
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
|
||||
"eqnull" : false, // Tolerate use of `== null`.
|
||||
//"es5" : true, // Allow ECMAScript 5 syntax.
|
||||
"esnext" : false, // Allow ES.next specific features such as const and let
|
||||
"evil" : false, // Tolerate use of `eval`.
|
||||
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
||||
"funcscope" : false, // Tolerate declaring variables inside of control structures while accessing them later
|
||||
"globalstrict" : true, // Allow global "use strict" (also enables 'strict').
|
||||
"iterator" : false, // Allow usage of __iterator__ property.
|
||||
"lastsemic" : false, // Tolerate semicolon omited for the last statement.
|
||||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
||||
"laxcomma" : true, // This option suppresses warnings about comma-first coding style
|
||||
"loopfunc" : false, // Allow functions to be defined within loops.
|
||||
"multistr" : false, // Tolerate multi-line strings.
|
||||
"proto" : false, // Allow usage of __proto__ property.
|
||||
"scripturl" : false, // Tolerate script-targeted URLs.
|
||||
"smarttabs" : false, // Allow mixed tabs and spaces when the latter are used for alignmnent only.
|
||||
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
||||
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
||||
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
||||
"validthis" : false, // true: Tolerate using this in a non-constructor function
|
||||
|
||||
// Environments //////////////////////////////////////////////////////////////
|
||||
|
||||
"browser" : false, // Defines globals exposed by modern browsers
|
||||
"couch" : false, // Defines globals exposed by CouchDB
|
||||
"devel" : false, // Allow developments statements e.g. `console.log();`.
|
||||
"dojo" : false, // Defines globals exposed by the Dojo Toolkit
|
||||
"jquery" : false, // Defines globals exposed by the jQuery
|
||||
"mootools" : false, // Defines globals exposed by the MooTools
|
||||
"node" : true, // Defines globals exposed when running under Node.JS
|
||||
"nonstandard" : false, // Defines non-standard but widely adopted globals such as escape and unescape
|
||||
"prototypejs" : false, // Defines globals exposed by the Prototype
|
||||
"rhino" : false, // Defines globals exposed when running under Rhino
|
||||
"wsh" : false, // Defines globals exposed when running under WSH
|
||||
"yui" : false, // Yahoo User Interface
|
||||
|
||||
// Legacy ////////////////////////////////////////////////////////////////////
|
||||
|
||||
"nomen" : false, // Prohibit use of initial or trailing underbars in names.
|
||||
"onevar" : false, // Allow only one `var` statement per function.
|
||||
"passfail" : false, // Stop on first error.
|
||||
"white" : false, // Check against strict whitespace and indentation rules.
|
||||
|
||||
// Custom globals ///////////////////////////////////////////////////////////
|
||||
|
||||
"globals" : { }
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
before_script: "npm install"
|
||||
script: make $COMMAND
|
||||
env:
|
||||
matrix:
|
||||
|
|
2
Makefile
2
Makefile
|
@ -23,7 +23,7 @@ help:
|
|||
|
||||
|
||||
lint:
|
||||
jshint . --show-non-errors
|
||||
eslint --reset .
|
||||
|
||||
|
||||
test: lint
|
||||
|
|
|
@ -20,8 +20,8 @@ var IMPLS = [];
|
|||
|
||||
|
||||
fs.readdirSync(IMPLS_DIRECTORY).sort().forEach(function (name) {
|
||||
var file = path.join(IMPLS_DIRECTORY, name),
|
||||
code = require(file);
|
||||
var file = path.join(IMPLS_DIRECTORY, name);
|
||||
var code = require(file);
|
||||
|
||||
IMPLS_PATHS[name] = file;
|
||||
IMPLS.push({
|
||||
|
@ -85,7 +85,7 @@ fs.readdirSync(SAMPLES_DIRECTORY).sort().forEach(function (sample) {
|
|||
defer: !!impl.code.async,
|
||||
|
||||
fn: function (deferred) {
|
||||
if (!!impl.code.async) {
|
||||
if (impl.code.async) {
|
||||
impl.code.run(content, LEVEL, function() {
|
||||
deferred.resolve();
|
||||
return;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var pako = require('../index.js');
|
||||
|
||||
var data = new Uint8Array(fs.readFileSync(__dirname +'/samples/lorem_1mb.txt'));
|
||||
var data = new Uint8Array(fs.readFileSync(path.join(__dirname, '/samples/lorem_1mb.txt')));
|
||||
|
||||
var deflated = pako.deflate(data, { level: 6/*, to: 'string'*/ });
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ exports.assign = function (obj /*from1, from2, from3, ...*/) {
|
|||
var source = sources.shift();
|
||||
if (!source) { continue; }
|
||||
|
||||
if (typeof(source) !== 'object') {
|
||||
if (typeof source !== 'object') {
|
||||
throw new TypeError(source + 'must be non-object');
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch(__) { STR_APPL
|
|||
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
|
||||
// because max possible codepoint is 0x10ffff
|
||||
var _utf8len = new utils.Buf8(256);
|
||||
for (var i=0; i<256; i++) {
|
||||
_utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);
|
||||
for (var q=0; q<256; q++) {
|
||||
_utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
|
||||
}
|
||||
_utf8len[254]=_utf8len[254]=1; // Invalid sequence start
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
// Small size is preferable.
|
||||
|
||||
function adler32(adler, buf, len, pos) {
|
||||
var s1 = (adler & 0xffff) |0
|
||||
, s2 = ((adler >>> 16) & 0xffff) |0
|
||||
, n = 0;
|
||||
var s1 = (adler & 0xffff) |0,
|
||||
s2 = ((adler >>> 16) & 0xffff) |0,
|
||||
n = 0;
|
||||
|
||||
while (len !== 0) {
|
||||
// Set limit ~ twice less than 5552, to keep
|
||||
|
|
|
@ -25,8 +25,8 @@ var crcTable = makeTable();
|
|||
|
||||
|
||||
function crc32(crc, buf, len, pos) {
|
||||
var t = crcTable
|
||||
, end = pos + len;
|
||||
var t = crcTable,
|
||||
end = pos + len;
|
||||
|
||||
crc = crc ^ (-1);
|
||||
|
||||
|
|
|
@ -196,12 +196,14 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta
|
|||
if (type === CODES) {
|
||||
base = extra = work; /* dummy value--not used */
|
||||
end = 19;
|
||||
|
||||
} else if (type === LENS) {
|
||||
base = lbase;
|
||||
base_index -= 257;
|
||||
extra = lext;
|
||||
extra_index -= 257;
|
||||
end = 256;
|
||||
|
||||
} else { /* DISTS */
|
||||
base = dbase;
|
||||
extra = dext;
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
"benchmark": "*",
|
||||
"ansi": "*",
|
||||
"browserify":"*",
|
||||
"eslint": "0.17.1",
|
||||
"eslint-plugin-nodeca": "~1.0.3",
|
||||
"uglify-js": "*",
|
||||
"jshint": "*",
|
||||
"istanbul": "*",
|
||||
"ndoc": "*",
|
||||
"lodash": "*",
|
||||
|
|
|
@ -18,7 +18,7 @@ var pako = require('../index');
|
|||
|
||||
|
||||
function h2b(hex) {
|
||||
return hex.split(' ').map(function(hex) { return parseInt(hex, 16); });
|
||||
return hex.split(' ').map(function(hx) { return parseInt(hx, 16); });
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,13 +18,12 @@ function fixedFromCharCode(code) {
|
|||
if (code > 0xffff) {
|
||||
code -= 0x10000;
|
||||
|
||||
var surrogate1 = 0xd800 + (code >> 10)
|
||||
, surrogate2 = 0xdc00 + (code & 0x3ff);
|
||||
var surrogate1 = 0xd800 + (code >> 10),
|
||||
surrogate2 = 0xdc00 + (code & 0x3ff);
|
||||
|
||||
return String.fromCharCode(surrogate1, surrogate2);
|
||||
} else {
|
||||
return String.fromCharCode(code);
|
||||
}
|
||||
return String.fromCharCode(code);
|
||||
}
|
||||
|
||||
// Converts array of codes / chars / strings to utf16 string
|
||||
|
|
Loading…
Add table
Reference in a new issue