Skip to content

Commit 525756a

Browse files
committed
Fixing issue 11
1 parent 033768f commit 525756a

File tree

3 files changed

+108
-52
lines changed

3 files changed

+108
-52
lines changed

FastIntegerCompression.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ FastIntegerCompression.compress = function(input) {
107107
// From a compressed array of integers stored ArrayBuffer,
108108
// compute the number of compressed integers by scanning the input.
109109
FastIntegerCompression.computeHowManyIntegers = function(input) {
110-
var view = new Int8Array(input);
110+
var view = new Uint8Array(input);
111111
var c = view.length;
112112
var count = 0;
113113
for(var i = 0; i < c; i++) {
114-
count += (input[i]>>>7);
114+
count += (view[i]>>>7);
115115
}
116116
return c - count;
117117
}

package-lock.json

Lines changed: 104 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unit/basictests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('FastIntegerCompression', function() {
1717
it('Testing simple compression', function() {
1818
var array = [10,100000,65999,10,10,0,1,1,2000,0xFFFFFFFF];
1919
var buf = FastIntegerCompression.compress(array);
20-
if(! FastIntegerCompression.computeHowManyIntegers(buf) == array.length) throw "bad count";
20+
if(FastIntegerCompression.computeHowManyIntegers(buf) !== array.length) throw "bad count";
2121
var back = FastIntegerCompression.uncompress(buf);
2222
if(!arraysEquals(array,back)) throw "bad";
2323

@@ -28,7 +28,7 @@ describe('FastIntegerCompression', function() {
2828
it('Testing simple compression (signed)', function() {
2929
var array = [10,100000,65999,10,10,0,-1,-1,-2000];
3030
var buf = FastIntegerCompression.compressSigned(array);
31-
if(! FastIntegerCompression.computeHowManyIntegers(buf) == array.length) throw "bad count";
31+
if(FastIntegerCompression.computeHowManyIntegers(buf) !== array.length) throw "bad count";
3232
var back = FastIntegerCompression.uncompressSigned(buf);
3333
if(!arraysEquals(array,back)) throw "bad";
3434

0 commit comments

Comments
 (0)