version bump 1.3.0

This commit is contained in:
SheetJS 2021-04-18 13:26:36 -04:00
parent 800b787dcf
commit b7700fd5fa
18 changed files with 44 additions and 32 deletions

View File

@ -2,7 +2,7 @@ LIB=adler32
REQS=
ADDONS=
AUXTARGETS=demo/browser.js
CMDS=bin/adler32.njs
CMDS=
HTMLLINT=index.html
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
@ -62,7 +62,7 @@ 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
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
.PHONY: old-lint

View File

@ -80,18 +80,19 @@ To generate the bits file, use the `adler32` function from python `zlib`:
2023497376
```
The included `adler32.njs` script can process files or standard input:
The [`adler32-cli`](https://www.npmjs.com/package/adler32-cli) package includes
scripts for processing files or text on standard input:
```bash
$ echo "this is a test" > t.txt
$ bin/adler32.njs t.txt
$ adler32-cli t.txt
726861088
```
For comparison, the included `adler32.py` script uses python `zlib`:
For comparison, the `adler32.py` script in the subdirectory uses python `zlib`:
```bash
$ bin/adler32.py t.txt
$ packages/adler32-cli/bin/adler32.py t.txt
726861088
```

View File

@ -10,7 +10,7 @@ var ADLER32/*:ADLER32Module*/;
if(typeof DO_NOT_EXPORT_ADLER === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
} else if ('function' === typeof define && /*::(*/define/*:: :any)*/.amd) {
define(function () {
var module/*:ADLER32Module*/ = /*::(*/{}/*:: :any)*/;
factory(module);
@ -25,7 +25,7 @@ var ADLER32/*:ADLER32Module*/;
/*eslint-enable */
/*jshint ignore:end */
}(function(ADLER32/*:ADLER32Module*/) {
ADLER32.version = '1.2.0';
ADLER32.version = '1.3.0';
/*::
type ADLER32Type = number;
type ABuf = Array<number> | Buffer | Uint8Array;

View File

@ -23,7 +23,7 @@ var ADLER32;
/*eslint-enable */
/*jshint ignore:end */
}(function(ADLER32) {
ADLER32.version = '1.2.0';
ADLER32.version = '1.3.0';
function adler32_bstr(bstr, seed) {
var a = 1, b = 0, L = bstr.length, M = 0;
if(typeof seed === 'number') { a = seed & 0xFFFF; b = seed >>> 16; }

View File

@ -10,7 +10,7 @@ var ADLER32/*:ADLER32Module*/;
if(typeof DO_NOT_EXPORT_ADLER === 'undefined') {
if('object' === typeof exports) {
factory(exports);
} else if ('function' === typeof define && define.amd) {
} else if ('function' === typeof define && /*::(*/define/*:: :any)*/.amd) {
define(function () {
var module/*:ADLER32Module*/ = /*::(*/{}/*:: :any)*/;
factory(module);

View File

@ -1 +1 @@
ADLER32.version = '1.2.0';
ADLER32.version = '1.3.0';

View File

@ -23,7 +23,7 @@ var ADLER32;
/*eslint-enable */
/*jshint ignore:end */
}(function(ADLER32) {
ADLER32.version = '1.2.0';
ADLER32.version = '1.3.0';
function adler32_bstr(bstr, seed) {
var a = 1, b = 0, L = bstr.length, M = 0;
if(typeof seed === 'number') { a = seed & 0xFFFF; b = seed >>> 16; }

View File

@ -34,8 +34,8 @@ type _CB = {(data:Buffer):void;};
declare module 'concat-stream' {declare function exports(f:_CB):stream$Duplex;};
declare module 'exit-on-epipe' {};
declare module 'adler-32' { declare var exports:ADLER32Module; };
declare module '../' { declare var exports:ADLER32Module; };
declare module 'adler-32' { declare module.exports:ADLER32Module; };
declare module '../' { declare module.exports:ADLER32Module; };
declare module 'printj' {
declare function sprintf(fmt:string, ...args:any):string;

View File

@ -19,6 +19,14 @@ function msieversion()
return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
}
var Buffer_from = function(){};
if(typeof Buffer !== 'undefined') {
var nbfs = !Buffer.from;
if(!nbfs) try { Buffer.from("foo", "utf8"); } catch(e) { nbfs = true; }
Buffer_from = nbfs ? function(buf, enc) { return (enc) ? new Buffer(buf, enc) : new Buffer(buf); } : Buffer.from.bind(Buffer);
}
describe('adler32 bits', function() {
bits.forEach(function(i) {
var msg = i[0], l = i[0].length, L = i[1]|0;
@ -28,7 +36,7 @@ describe('adler32 bits', function() {
it(msg, function() {
if(i[2] === 1) assert.equal(X.bstr(i[0]), L);
assert.equal(X.str(i[0]), i[1]|0);
if(typeof Buffer !== 'undefined') assert.equal(X.buf(new Buffer(i[0])), L);
if(typeof Buffer !== 'undefined') assert.equal(X.buf(Buffer_from(i[0])), L);
var len = i[0].length, step = len < 20000 ? 1 : len < 50000 ? Math.ceil(len / 20000) : Math.ceil(len / 2000);
for(var x = 0; x < len; x += step) {
if(i[0].charCodeAt(x) >= 0xD800 && i[0].charCodeAt(x) < 0xE000) continue;
@ -39,7 +47,7 @@ describe('adler32 bits', function() {
var stradl = X.str(i[0].substr(x), X.str(i[0].substr(0, x)));
assert.equal(stradl, i[1]|0);
if(typeof Buffer !== 'undefined') {
var buf = new Buffer(i[0]);
var buf = Buffer_from(i[0]);
var bufadl = X.buf(buf.slice(x), X.buf(buf.slice(0, x)));
assert.equal(bufadl, L);
}
@ -62,9 +70,9 @@ if(typeof require !== 'undefined') describe("unicode", function() {
var cc = corpus[ucidx], dd = X.str(c);
assert.equal(dd, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + dd);
if(typeof Buffer !== 'undefined') {
var ee = X.buf(new Buffer(c, "utf8"));
var ee = X.buf(Buffer_from(c, "utf8"));
assert.equal(ee, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + ee);
var ff = X.bstr(String.fromCharCode.apply(null, new Buffer(c, "utf8")));
var ff = X.bstr(String.fromCharCode.apply(null, Buffer_from(c, "utf8")));
assert.equal(ff, cc, ":" + ucidx + ":" + c + ":" + cc + ":" + ff);
}
};

View File

@ -1,6 +1,6 @@
/*jshint browser:true */
/*eslint-env browser */
/*global ADLER32, console, Uint8Array */
/*global ADLER32, Uint8Array */
/*:: declare var ADLER32: ADLER32Module; */
var X = ADLER32;

View File

@ -1,6 +1,6 @@
/*jshint browser:true */
/*eslint-env browser */
/*global ADLER32, console, Uint8Array */
/*global ADLER32, Uint8Array */
var X = ADLER32;
function console_log() { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); }

View File

@ -11,7 +11,7 @@ var readler = function(f, adler, l) {
var d = f.slice(l, l + sz);
var r = new FileReader();
r.onload = function(e) {
var b = new Uint8Array(e.target.result);
var b = new Uint8Array((e.target/*:any*/).result);
var newadler = ADLER32.buf(b, adler);
/*::self.*/postMessage({t:"data", adler:newadler, bytes:l+sz});
readler(f, newadler, l + sz);

View File

@ -1,14 +1,13 @@
{
"name": "adler-32",
"version": "1.2.0",
"version": "1.3.0",
"author": "sheetjs",
"description": "Pure-JS ADLER-32",
"keywords": [ "adler32", "checksum" ],
"main": "./adler32",
"types": "types",
"dependencies": {
"printj": "~1.1.0",
"exit-on-epipe": "~1.0.1"
"printj": "~1.2.2"
},
"devDependencies": {
"mocha": "~2.5.3",
@ -32,7 +31,7 @@
}
},
"homepage": "http://sheetjs.com/opensource",
"files": ["adler32.js", "bin/adler32.njs", "LICENSE", "README.md", "types/index.d.ts", "types/*.json"],
"files": ["adler32.js", "LICENSE", "README.md", "types/index.d.ts", "types/*.json"],
"bugs": { "url": "https://github.com/SheetJS/js-adler32/issues" },
"license": "Apache-2.0",
"engines": { "node": ">=0.8" }

View File

@ -0,0 +1,2 @@
*.tgz
*.py

View File

@ -4,8 +4,7 @@
/* vim: set ts=2 ft=javascript: */
/*jshint node:true */
/*:ADLER32Module*/
var X = require('adler32');
var X/*:ADLER32Module*/ = require('adler-32');
function help()/*:number*/ {
[

View File

@ -1,6 +1,6 @@
{
"name": "adler32-cli",
"version": "1.0.2",
"version": "1.0.3",
"description": "Command-line interface for adler32",
"main": "index.js",
"bin": {
@ -9,8 +9,7 @@
"author": "Garrett Luu",
"license": "Apache-2.0",
"dependencies": {
"adler32": "^0.1.7",
"exit-on-epipe": "^1.0.1",
"fs": "0.0.1-security"
"adler-32": "^1.3.0",
"printj": "~1.2.2"
}
}

View File

@ -9,6 +9,7 @@
"paths": { "adler-32": ["."] },
"types": [],
"noEmit": true,
"strictFunctionTypes": true,
"forceConsistentCasingInFileNames": true
}
}

View File

@ -1,11 +1,14 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"no-implicit-dependencies": false,
"whitespace": false,
"no-sparse-arrays": false,
"only-arrow-functions": false,
"no-consecutive-blank-lines": false,
"prefer-conditional-expression": false,
"one-variable-per-declaration": false
"one-variable-per-declaration": false,
"strict-export-declare-modifiers": false,
"prefer-template": false
}
}