version bump 1.2.0: infrastructure

This commit is contained in:
SheetJS 2018-01-17 16:27:59 -05:00
parent 2253617eae
commit 02caecf54f
20 changed files with 109 additions and 63 deletions

View File

@ -5,14 +5,14 @@
"ecmaVersion": 3,
},
"plugins": [ "html", "json" ],
"!extends": "eslint:recommended",
"extends": "eslint:recommended",
"rules": {
"no-console": 0,
"no-bitwise": 0,
"curly": 0,
"comma-style": [ 2, "last" ],
"comma-dangle": [ 2, "never" ],
"curly": 0,
"no-bitwise": 0,
"no-console": 0,
"no-trailing-spaces": 2,
"semi": [ 2, "always" ],
"comma-dangle": [ 2, "never" ]
"semi": [ 2, "always" ]
}
}

10
.spelling Normal file
View File

@ -0,0 +1,10 @@
# crc32.js (C) 2014-present SheetJS -- http://sheetjs.com
SheetJS
32-bit
CRC-32
UCS-2
UTF-8
crc32
checksum
nodejs
npm

View File

@ -1,5 +1,6 @@
language: node_js
node_js:
- "9"
- "8"
- "7"
- "6"

View File

@ -57,6 +57,9 @@ clean-baseline: ## Remove test baselines
## Code Checking
.PHONY: fullint
fullint: lint old-lint tslint flow mdlint ## Run all checks
.PHONY: lint
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json
@ -74,7 +77,8 @@ old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
.PHONY: tslint
tslint: $(TARGET) ## Run typescript checks
#@npm install dtslint typescript
@npm run-script dtslint
#@npm run-script dtslint
dtslint types
.PHONY: flow
flow: lint ## Run flow checker
@ -84,12 +88,18 @@ flow: lint ## Run flow checker
cov: misc/coverage.html ## Run coverage test
misc/coverage.html: $(TARGET) test.js
mocha --require blanket -R html-cov -t 20000 > $@
mocha --require blanket -R html-cov -t 30000 > $@
.PHONY: coveralls
coveralls: ## Coverage Test + Send to coveralls.io
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js
MDLINT=README.md
.PHONY: mdlint
mdlint: $(MDLINT) ## Check markdown documents
alex $^
mdspell -a -n -x -r --en-us $^
.PHONY: perf
perf: ## Run Performance Tests
@bash perf/perf.sh

View File

@ -22,9 +22,8 @@ The browser exposes a variable `CRC32`.
When installed globally, npm installs a script `crc32` that computes the
checksum for a specified file or standard input.
The script will manipulate `module.exports` if available (e.g. in a CommonJS
`require` context). This is not always desirable. To prevent the behavior,
define `DO_NOT_EXPORT_CRC`.
The script will manipulate `module.exports` if available . This is not always
desirable. To prevent the behavior, define `DO_NOT_EXPORT_CRC`.
## Usage
@ -34,13 +33,13 @@ optional second argument representing the starting "seed" (for rolling CRC).
The return value is a signed 32-bit integer.
- `CRC32.buf(byte array or buffer[, seed])` assumes the argument is a sequence
of 8-bit unsigned integers (e.g. nodejs `Buffer` or simple array of ints).
of 8-bit unsigned integers (nodejs `Buffer`, `Uint8Array` or array of bytes).
- `CRC32.bstr(binary string[, seed])` assumes the argument is a "binary" string
- `CRC32.bstr(binary string[, seed])` assumes the argument is a binary string
where byte `i` is the low byte of the UCS-2 char: `str.charCodeAt(i) & 0xFF`
- `CRC32.str(string[, seed])` assumes the argument is a standard string and
calculates the CRC32 of the UTF-8 encoding.
- `CRC32.str(string[, seed])` assumes the argument is a standard JS string and
calculates the hash of the UTF-8 encoding.
For example:
@ -68,7 +67,7 @@ To run the in-browser tests, run a local server and go to the `ctest` directory.
To update the browser artifacts, run `make ctest`.
To generate the bits file, use the `crc32` function from python zlib:
To generate the bits file, use the `crc32` function from python `zlib`:
```python
>>> from zlib import crc32
@ -81,7 +80,7 @@ To generate the bits file, use the `crc32` function from python zlib:
1834240887
```
The included `crc32.njs` script can process files or stdin:
The included `crc32.njs` script can process files or standard input:
```bash
$ echo "this is a test" > t.txt
@ -89,7 +88,7 @@ $ bin/crc32.njs t.txt
1912935186
```
For comparison, the included `crc32.py` script uses python zlib:
For comparison, the included `crc32.py` script uses python `zlib`:
```bash
$ bin/crc32.py t.txt
@ -110,7 +109,7 @@ $ crc32 --unsigned ~/Downloads/IE8.Win7.For.Windows.VMware.zip
`make perf` will run algorithmic performance tests (which should justify certain
decisions in the code).
[js-adler32](http://git.io/adler32) has more performance notes
The [`adler-32` project](http://git.io/adler32) has more performance notes
## License

View File

@ -1,6 +1,8 @@
#!/usr/bin/env node
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* vim: set ts=2 ft=javascript: */
/*jshint node:true */
var X/*:CRC32Module*/;
try { X = require('../'); } catch(e) { X = require('crc-32'); }

View File

@ -1,25 +1,27 @@
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported CRC32 */
var CRC32;
/*:: declare var DO_NOT_EXPORT_CRC: any; */
/*:: declare var define: any; */
(function (factory) {
/*:: declare var DO_NOT_EXPORT_CRC:?boolean; */
/*:: declare function define(cb:()=>any):void; */
var CRC32/*:CRC32Module*/;
(function (factory/*:(a:any)=>void*/)/*:void*/ {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module = {};
var module/*:CRC32Module*/ = /*::(*/{}/*:: :any)*/;
factory(module);
return module;
});
} else {
factory(CRC32 = {});
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
} else {
factory(CRC32 = {});
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32) {
}(function(CRC32/*:CRC32Module*/) {

View File

@ -1 +1 @@
CRC32.version = '1.1.1';
CRC32.version = '1.2.0';

View File

@ -1,5 +1,5 @@
/*::
type CRC32Type = number;
type ABuf = Array<number> | Uint8Array | Buffer;
type ABuf = Array<number> | Buffer | Uint8Array;
type CRC32TableType = Array<number> | Int32Array;
*/

View File

@ -1,4 +1,7 @@
CRC32.table = T;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;

View File

@ -1,32 +1,34 @@
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* vim: set ts=2: */
/*exported CRC32 */
var CRC32;
/*:: declare var DO_NOT_EXPORT_CRC: any; */
/*:: declare var define: any; */
(function (factory) {
/*:: declare var DO_NOT_EXPORT_CRC:?boolean; */
/*:: declare function define(cb:()=>any):void; */
var CRC32/*:CRC32Module*/;
(function (factory/*:(a:any)=>void*/)/*:void*/ {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
define(function () {
var module = {};
var module/*:CRC32Module*/ = /*::(*/{}/*:: :any)*/;
factory(module);
return module;
});
} else {
factory(CRC32 = {});
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
} else {
factory(CRC32 = {});
factory(CRC32 = /*::(*/{}/*:: :any)*/);
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32) {
CRC32.version = '1.1.1';
}(function(CRC32/*:CRC32Module*/) {
CRC32.version = '1.2.0';
/*::
type CRC32Type = number;
type ABuf = Array<number> | Uint8Array | Buffer;
type ABuf = Array<number> | Buffer | Uint8Array;
type CRC32TableType = Array<number> | Int32Array;
*/
/* see perf/crc32table.js */
@ -116,7 +118,10 @@ function crc32_str(str/*:string*/, seed/*:?CRC32Type*/)/*:CRC32Type*/ {
return C ^ -1;
}
CRC32.table = T;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;
}));

View File

@ -4,6 +4,7 @@
var CRC32;
(function (factory) {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
@ -19,9 +20,10 @@ var CRC32;
} else {
factory(CRC32 = {});
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32) {
CRC32.version = '1.1.1';
CRC32.version = '1.2.0';
/* see perf/crc32table.js */
/*global Int32Array */
function signed_crc_table() {
@ -107,7 +109,10 @@ function crc32_str(str, seed) {
return C ^ -1;
}
CRC32.table = T;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;
}));

View File

@ -4,6 +4,7 @@
var CRC32;
(function (factory) {
/*jshint ignore:start */
/*eslint-disable */
if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
if('object' === typeof exports) {
factory(exports);
@ -19,9 +20,10 @@ var CRC32;
} else {
factory(CRC32 = {});
}
/*eslint-enable */
/*jshint ignore:end */
}(function(CRC32) {
CRC32.version = '1.1.1';
CRC32.version = '1.2.0';
/* see perf/crc32table.js */
/*global Int32Array */
function signed_crc_table() {
@ -107,7 +109,10 @@ function crc32_str(str, seed) {
return C ^ -1;
}
CRC32.table = T;
// $FlowIgnore
CRC32.bstr = crc32_bstr;
// $FlowIgnore
CRC32.buf = crc32_buf;
// $FlowIgnore
CRC32.str = crc32_str;
}));

View File

@ -22,14 +22,11 @@ var bits = [
];
if(typeof module !== "undefined") module.exports = bits;
/*::
type ArrayLike = any;
type Stringifier = {(d:ArrayLike):string};
declare class CRC32Module {
table:CRC32TableType;
bstr(s:string, seed:?CRC32Type):CRC32Type;
buf(b:ABuf, seed:?CRC32Type):CRC32Type;
str(s:string, seed:?CRC32Type):CRC32Type;
bstr(s:string, seed?:CRC32Type):CRC32Type;
buf(b:ABuf, seed?:CRC32Type):CRC32Type;
str(s:string, seed?:CRC32Type):CRC32Type;
version:string;
};
*/

View File

@ -1,5 +1,6 @@
/*jshint browser:true */
/*global CRC32, console */
/*eslint-env browser */
/*global CRC32, console, Uint8Array */
/*:: declare var CRC32: CRC32Module; */
var X = CRC32;
@ -17,6 +18,10 @@ function is_defined(val/*:any*/, keys/*:Array<string>*/)/*:boolean*/ {
}
/*# buffer to string; IE String.fromCharCode.apply limit, manual chunk */
/*::
type ArrayLike = any;
type Stringifier = {(d:ArrayLike):string};
*/
function make_chunk_buf_to_str(BType/*:function*/)/*:Stringifier*/ {
return function(data/*:any*/)/*:string*/ {
var o = "", l = 0, w = 10240, L = data.byteLength/w;
@ -66,7 +71,7 @@ var readcb = function(e/*:Event*/) {
console_log("onload", new Date(), rABS, false);
var target/*:FileReader*/ = (e.target/*:any*/);
var data = target.result;
var val/*:CRC32Type*/ = rABS ? X.bstr((data/*:any*/)) : X.str(bstrify(data));
var val/*:CRC32Type*/ = rABS ? X.bstr(/*::(*/data/*:: :any)*/) : X.str(bstrify(data));
process_value(val);
};

View File

@ -1,5 +1,6 @@
/*jshint browser:true */
/*global CRC32, console */
/*eslint-env browser */
/*global CRC32, console, Uint8Array */
var X = CRC32;
function console_log() { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); }
@ -57,7 +58,7 @@ var readcb = function(e) {
console_log("onload", new Date(), rABS, false);
var target = (e.target);
var data = target.result;
var val = rABS ? X.bstr((data)) : X.str(bstrify(data));
var val = rABS ? X.bstr(data) : X.str(bstrify(data));
process_value(val);
};

View File

@ -27,8 +27,8 @@ a { text-decoration: none }
(text works back to IE6; drag and drop works back to IE10)
(<b>This demo loads the entire file at once!</b> For newer browsers, <a href="large.html">try the large file demo</a>)
<a href="https://github.com/SheetJS/js-crc32">Source Code Repo</a>
<a href="https://github.com/SheetJS/js-crc32/issues">Issues? Something look weird? Click here and report an issue</a>
<a href="https://git.io/crc32">Source Code Repo</a>
<a href="https://git.io/crc32_issues">Issues? Something look weird? Click here and report an issue</a>
<br />
<div id="drop">Drop a text file to compute the CRC-32 checksum</div>
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
@ -36,7 +36,7 @@ a { text-decoration: none }
<textarea id="rawdata">... or paste text here</textarea>
<input type="button" id="dotext" value="Click here to process the text"/><br />
<b>Advanced Demo Options:</b>
Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked>
Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked><br />
</pre>
<pre id="out"></pre>
<br />
@ -45,6 +45,7 @@ Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" c
<script src="crc32.js"></script>
<script src="demo/browser.flow.js"></script>
<script type="text/javascript">
/*eslint-env browser */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36810333-1']);
_gaq.push(['_trackPageview']);

View File

@ -1,12 +1,9 @@
/*::
type ArrayLike = any;
type Stringifier = {(d:ArrayLike):string};
declare class CRC32Module {
table:CRC32TableType;
bstr(s:string, seed:?CRC32Type):CRC32Type;
buf(b:ABuf, seed:?CRC32Type):CRC32Type;
str(s:string, seed:?CRC32Type):CRC32Type;
bstr(s:string, seed?:CRC32Type):CRC32Type;
buf(b:ABuf, seed?:CRC32Type):CRC32Type;
str(s:string, seed?:CRC32Type):CRC32Type;
version:string;
};
*/

View File

@ -1,9 +1,9 @@
{
"name": "crc-32",
"version": "1.1.1",
"version": "1.2.0",
"author": "sheetjs",
"description": "Pure-JS CRC-32",
"keywords": [ "crc32", "checksum", "crc" ],
"keywords": [ "crc", "crc32", "checksum" ],
"bin": {
"crc32": "./bin/crc32.njs"
},
@ -25,6 +25,8 @@
"repository": { "type":"git", "url":"git://github.com/SheetJS/js-crc32.git" },
"scripts": {
"test": "make test",
"build": "make",
"lint": "make fullint",
"dtslint": "dtslint types"
},
"config": {
@ -33,7 +35,7 @@
}
},
"homepage": "http://sheetjs.com/opensource",
"files": ["crc32.js", "bin/crc32.njs", "LICENSE", "README.md"],
"files": ["crc32.js", "bin/crc32.njs", "LICENSE", "README.md", "types/index.d.ts", "types/*.json"],
"bugs": { "url": "https://github.com/SheetJS/js-crc32/issues" },
"license": "Apache-2.0",
"engines": { "node": ">=0.8" }

View File

@ -1,6 +1,7 @@
/* crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* vim: set ts=2 ft=javascript: */
/*jshint node:true */
/// <reference types="../node_modules/@types/node/" />
/* node type definition is missing writable stream _writev */
interface Chunk { chunk: any; encoding: string; }