You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an integer compression library in JavaScript, useful for work on indexes.
6
-
Given an array of small non-negative integers, it produces an ArrayBuffer that uses far fewer bytes
6
+
Given an array of small integers, it produces an ArrayBuffer that uses far fewer bytes
7
7
than the original (using VByte compression). It assumes a modern JavaScript engine with
8
8
typed arrays.
9
9
@@ -18,6 +18,17 @@ From the compressed data, you can later recover the original array quickly
18
18
var back =FastIntegerCompression.uncompress(buf); // gets back [10,100000,65999,10,10,0,1,1,2000]
19
19
```
20
20
21
+
By default, non-negative integers are expected. If you have signed (negative and positive) integers, then you must use distinct functions since we need to code the sign bit:
22
+
23
+
24
+
```javascript
25
+
// var FastIntegerCompression = require("fastintcompression");// if you use node
26
+
var array = [10,100000,65999,10,10,0,-1,-1,-2000];
27
+
var buf =FastIntegerCompression.compressSigned(array);
28
+
var back =FastIntegerCompression.uncompressSigned(buf); // gets back [10,100000,65999,10,10,0,-1,-1,-2000]
29
+
```
30
+
31
+
21
32
You can install the library under node with the command line
0 commit comments