version bump 1.1.0: pin dependencies
This commit is contained in:
parent
844c43bc18
commit
06fac2b063
@ -25,3 +25,5 @@ misc/flowdeps.js
|
||||
[options]
|
||||
module.file_ext=.js
|
||||
module.file_ext=.njs
|
||||
module.ignore_non_literal_requires=true
|
||||
suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
|
||||
|
@ -23,7 +23,7 @@ var ADLER32;
|
||||
}
|
||||
/*jshint ignore:end */
|
||||
}(function(ADLER32) {
|
||||
ADLER32.version = '1.0.0';
|
||||
ADLER32.version = '1.1.0';
|
||||
/*::
|
||||
type ADLER32Type = number;
|
||||
type ABuf = Array<number> | Buffer;
|
||||
|
@ -21,7 +21,7 @@ var ADLER32;
|
||||
}
|
||||
/*jshint ignore:end */
|
||||
}(function(ADLER32) {
|
||||
ADLER32.version = '1.0.0';
|
||||
ADLER32.version = '1.1.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; }
|
||||
|
@ -68,11 +68,18 @@ for(var i = 0; i < args.length; ++i) {
|
||||
if(!process.stdin.isTTY) filename = filename || "-";
|
||||
if(filename.length===0) die("adler32: must specify a filename ('-' for stdin)",1);
|
||||
|
||||
function process_data(data/*:Buffer*/) {
|
||||
var out/*:ADLER32Type*/ = X.buf(data, seed);
|
||||
return console.log(fmt === "" ? out : require("printj").sprintf(fmt, out));
|
||||
}
|
||||
var adler32 = seed;
|
||||
// $FlowIgnore -- Writable is callable but type sig disagrees
|
||||
var writable = require('stream').Writable();
|
||||
writable._write = function(chunk, e, cb) { adler32 = X.buf(chunk, adler32); cb(); };
|
||||
writable._writev = function(chunks, cb) {
|
||||
chunks.forEach(function(c) { adler32 = X.buf(c.chunk, adler32);});
|
||||
cb();
|
||||
};
|
||||
writable.on('finish', function() {
|
||||
console.log(fmt === "" ? adler32 : require("printj").sprintf(fmt, adler32));
|
||||
});
|
||||
|
||||
if(filename === "-") process.stdin.pipe(require('concat-stream')(process_data));
|
||||
else if(fs.existsSync(filename)) process_data(fs.readFileSync(filename));
|
||||
if(filename === "-") process.stdin.pipe(writable);
|
||||
else if(fs.existsSync(filename)) fs.createReadStream(filename).pipe(writable);
|
||||
else die("adler32: " + filename + ": No such file or directory", 2);
|
||||
|
@ -1 +1 @@
|
||||
ADLER32.version = '1.0.0';
|
||||
ADLER32.version = '1.1.0';
|
||||
|
@ -21,7 +21,7 @@ var ADLER32;
|
||||
}
|
||||
/*jshint ignore:end */
|
||||
}(function(ADLER32) {
|
||||
ADLER32.version = '1.0.0';
|
||||
ADLER32.version = '1.1.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; }
|
||||
|
@ -2,7 +2,6 @@
|
||||
/*global ADLER32, console */
|
||||
var X = ADLER32;
|
||||
|
||||
// $FlowIgnore
|
||||
function console_log() { if(typeof console !== 'undefined') console.log.apply(console, [].slice.call(arguments)); }
|
||||
|
||||
function lpad(s, len, chr){
|
||||
|
28
demo/work.js
Normal file
28
demo/work.js
Normal file
@ -0,0 +1,28 @@
|
||||
/* js-adler32 (C) 2014-present SheetJS -- http://sheetjs.com */
|
||||
/*:: declare var ADLER32: ADLER32Module; */
|
||||
/*:: declare var self: DedicatedWorkerGlobalScope; */
|
||||
importScripts('../adler32.js');
|
||||
/*::self.*/postMessage({t:"ready"});
|
||||
|
||||
var readler = function(f, adler, l) {
|
||||
/*::self.*/postMessage({t:"iter", f:f, adler:adler, l:l, sz:f.size});
|
||||
if(l >= f.size) return /*::self.*/postMessage({t:"done"});
|
||||
var sz = 0x100000; if(l + sz > f.size) sz = f.size - l;
|
||||
var d = f.slice(l, l + sz);
|
||||
var r = new FileReader();
|
||||
r.onload = function(e) {
|
||||
var b = new Uint8Array(e.target.result);
|
||||
var newadler = ADLER32.buf(b, adler);
|
||||
/*::self.*/postMessage({t:"data", adler:newadler, bytes:l+sz});
|
||||
readler(f, newadler, l + sz);
|
||||
};
|
||||
r.readAsArrayBuffer(d);
|
||||
};
|
||||
|
||||
onmessage = function (oEvent) {
|
||||
/*::self.*/postMessage({t:"start"});
|
||||
var f/*:File*/ = oEvent.data;
|
||||
var seed = 1;
|
||||
readler(f, seed, 0);
|
||||
};
|
||||
|
69
demo/worker.flow.js
Normal file
69
demo/worker.flow.js
Normal file
@ -0,0 +1,69 @@
|
||||
/*jshint browser:true */
|
||||
|
||||
function lpad(s/*:string*/, len/*:number*/, chr/*:?string*/)/*:string*/{
|
||||
var L/*:number*/ = len - s.length, C/*:string*/ = chr || " ";
|
||||
if(L <= 0) return s;
|
||||
return new Array(L+1).join(C) + s;
|
||||
}
|
||||
|
||||
function is_defined(val/*:any*/, keys/*:Array<string>*/)/*:boolean*/ {
|
||||
if(typeof val === "undefined") return false;
|
||||
return keys.length === 0 || is_defined(val[keys[0]], keys.slice(1));
|
||||
}
|
||||
|
||||
/*## Process Result */
|
||||
/*:: declare class HTMLPreElement extends HTMLElement { innerText?:string; } */
|
||||
function process_value(val/*:ADLER32Type*/, progress/*:number*/) {
|
||||
var output = [];
|
||||
output[0] = "Progress : %" + lpad(progress.toFixed(2), 6, " ");
|
||||
output[1] = "Signed : " + val;
|
||||
output[2] = "Unsigned : " + (val>>>0);
|
||||
output[3] = "Hex value : " + lpad((val>>>0).toString(16),8,'0');
|
||||
|
||||
var out/*:HTMLPreElement*/ = (document.getElementById('out')/*:any*/);
|
||||
var o = output.join("\n");
|
||||
if(typeof out.innerText == "undefined") out.textContent = o;
|
||||
else out.innerText = o;
|
||||
}
|
||||
|
||||
/*::
|
||||
type WMessage = {
|
||||
t:string;
|
||||
f:File;
|
||||
adler:ADLER32Type;
|
||||
l:number;
|
||||
sz:number;
|
||||
bytes:number;
|
||||
};
|
||||
*/
|
||||
|
||||
/*# Drag and Drop File */
|
||||
var handle_drop/*:EventHandler*/ = (function(e/*:DragEvent*/) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if(!e.dataTransfer) return;
|
||||
var files/*:FileList*/ = e.dataTransfer.files;
|
||||
var f/*:File*/ = files[0];
|
||||
|
||||
var worker = new Worker("demo/work.js");
|
||||
worker.postMessage(f);
|
||||
worker.onmessage = function(M) { var m/*:WMessage*/ = (M.data/*:any*/); switch(m.t) {
|
||||
case 'ready': break;
|
||||
case 'start': break;
|
||||
case 'data': process_value(m.adler, 100 * m.bytes / f.size); break;
|
||||
case 'done': break;
|
||||
} };
|
||||
}/*:any*/);
|
||||
|
||||
var handle_drag/*:EventHandler*/ = (function (e/*:DragEvent*/) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if(e.dataTransfer) e.dataTransfer.dropEffect = 'copy';
|
||||
}/*:any*/);
|
||||
|
||||
var drop/*:HTMLDivElement*/ = (document.getElementById('drop')/*:any*/);
|
||||
if(drop.addEventListener) {
|
||||
drop.addEventListener('dragenter', handle_drag, false);
|
||||
drop.addEventListener('dragover', handle_drag, false);
|
||||
drop.addEventListener('drop', handle_drop, false);
|
||||
}
|
23
index.html
23
index.html
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- adler32.js (C) 2014-present SheetJS http://sheetjs.com -->
|
||||
<!-- adler32.js (C) 2014-present SheetJS http://sheetjs.com -->
|
||||
<!-- vim: set ts=2: -->
|
||||
<html>
|
||||
<head>
|
||||
@ -18,20 +18,27 @@
|
||||
#rawdata{
|
||||
width:100%;
|
||||
}
|
||||
a { text-decoration: none }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<b>JS-ADLER32 Live Demo</b><br />
|
||||
<a href="https://git.io/adler32">Source Code Repo</a><br />
|
||||
<a href="https://git.io/adler32_issues">Issues? Something look weird? Click here and report an issue</a><br />
|
||||
<pre>
|
||||
<b><a href="http://sheetjs.com/bits">SheetJS JS-ADLER32 Live Demo</a></b>
|
||||
(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://git.io/adler32">Source Code Repo</a>
|
||||
<a href="https://git.io/adler32_issues">Issues? Something look weird? Click here and report an issue</a>
|
||||
<br />
|
||||
<div id="drop">Drop a text file to compute the ADLER-32 checksum</div>
|
||||
<p><input type="file" name="xlfile" id="xlf" /> ... or click here to select a file</p>
|
||||
<textarea id="rawdata">... or paste text here ......</textarea>
|
||||
<input type="file" name="xlfile" id="xlf" /> ... or click here to select a file
|
||||
|
||||
<textarea id="rawdata">... or paste text here</textarea>
|
||||
<input type="button" id="dotext" value="Click here to process the text"/><br />
|
||||
Advanced Demo Options: <br />
|
||||
<b>Advanced Demo Options:</b>
|
||||
Use readAsBinaryString: (when available) <input type="checkbox" name="userabs" checked><br />
|
||||
<pre id="out">.</pre>
|
||||
</pre>
|
||||
<pre id="out"></pre>
|
||||
<br />
|
||||
<script type="text/javascript">/* jshint browser: true */</script>
|
||||
<script src="shim.js"></script>
|
||||
|
52
large.html
Normal file
52
large.html
Normal file
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- adler32.js (C) 2014-present SheetJS http://sheetjs.com -->
|
||||
<!-- vim: set ts=2: -->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>JS-ADLER32 Live Demo</title>
|
||||
<style>
|
||||
#drop{
|
||||
border:2px dashed #bbb;
|
||||
-moz-border-radius:5px;
|
||||
-webkit-border-radius:5px;
|
||||
border-radius:5px;
|
||||
padding:25px;
|
||||
text-align:center;
|
||||
font:20pt bold,"Vollkorn";color:#bbb
|
||||
}
|
||||
#rawdata{
|
||||
width:100%;
|
||||
}
|
||||
a { text-decoration: none }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<pre>
|
||||
<b><a href="http://sheetjs.com/bits">SheetJS JS-ADLER32 Live Demo</a></b>
|
||||
(text works back to IE6; drag and drop works back to IE10)
|
||||
|
||||
<a href="https://git.io/adler32">Source Code Repo</a>
|
||||
<a href="https://git.io/adler32_issues">Issues? Something look weird? Click here and report an issue</a>
|
||||
<br />
|
||||
<div id="drop">Drop a text file to compute the ADLER-32 checksum</div>
|
||||
|
||||
<pre id="out"></pre>
|
||||
<br />
|
||||
<script type="text/javascript">/* jshint browser: true */</script>
|
||||
<script src="shim.js"></script>
|
||||
<script src="adler32.js"></script>
|
||||
<script src="demo/worker.flow.js"></script>
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-36810333-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "adler-32",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"author": "sheetjs",
|
||||
"description": "Pure-JS ADLER-32",
|
||||
"keywords": [ "adler32", "checksum" ],
|
||||
@ -9,13 +9,12 @@
|
||||
},
|
||||
"main": "./adler32",
|
||||
"dependencies": {
|
||||
"concat-stream":"",
|
||||
"printj":"",
|
||||
"exit-on-epipe":""
|
||||
"printj":"~1.1.0",
|
||||
"exit-on-epipe":"~1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha":"",
|
||||
"codepage":""
|
||||
"mocha":"~2.5.3",
|
||||
"codepage":"~1.10.0"
|
||||
},
|
||||
"repository": { "type":"git", "url":"git://github.com/SheetJS/js-adler32.git" },
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user