# fastintcompression

> a fast integer compression library in JavaScript

Latest version **0.1.0** (published 2023-04-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install fastintcompression
pnpm add fastintcompression
yarn add fastintcompression
bun add fastintcompression
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-04-02 |
| First published | 2016-04-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 64 |
| Author | Daniel Lemire |
| Maintainers | lemire |
| Keywords | integers, compression, performance |

## Links

- npm: https://www.npmjs.com/package/fastintcompression
- Repository: https://github.com/lemire/FastIntegerCompression.js
- Homepage: https://github.com/lemire/FastIntegerCompression.js#readme
- Issues: https://github.com/lemire/FastIntegerCompression.js/issues
- npm.io page: https://npm.io/package/fastintcompression

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2023-04-02
- 0.0.4 — 2020-09-04
- 0.0.3 — 2019-09-16
- 0.0.2 — 2017-04-14
- 0.0.1 — 2016-04-14

## README

# FastIntegerCompression
[![Build Status](https://travis-ci.org/lemire/FastIntegerCompression.js.png)](https://travis-ci.org/lemire/FastIntegerCompression.js)

This is an integer compression library in JavaScript, useful for work on indexes.
Given an array of small integers, it produces an ArrayBuffer that uses far fewer bytes
than the original (using VByte compression). It assumes a modern JavaScript engine with
typed arrays.
 
From the compressed data, you can later recover the original  array quickly 
(at a rate of millions of integers per second).


```javascript
   // var FastIntegerCompression = require("fastintcompression");// if you use node
   var array = [10,100000,65999,10,10,0,1,1,2000,0xFFFFFFFF];
   var buf = FastIntegerCompression.compress(array);
   var back = FastIntegerCompression.uncompress(buf); // gets back [10,100000,65999,10,10,0,1,1,2000]
``` 

By default, non-negative 32-bit integers are expected. If you have signed (negative and positive) 32-bit integers, then you must use distinct functions since we need to code the sign bit:


```javascript
   // var FastIntegerCompression = require("fastintcompression");// if you use node
   var array = [10,100000,65999,10,10,0,-1,-1,-2000];
   var buf = FastIntegerCompression.compressSigned(array);
   var back = FastIntegerCompression.uncompressSigned(buf); // gets back [10,100000,65999,10,10,0,-1,-1,-2000]
``` 


You can install the library under node with the command line
```bash
   npm install fastintcompression
```

This code is made available under the Apache License 2.0.

## Suitability 

This library is meant to compress arrays of small integers. It is not meant to
compress text documents or arrays of large (or random) integers.

## Performance numbers

Go to benchmark repository (check the README.md file) and run the benchmark:

```bash
$ node test.js
Platform: linux 3.13.0-91-generic x64
Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Node version 4.5.0, v8 version 4.5.103.37

input size: 7.813K compressed size: 1000B
FastIntegerCompression.compress x 337,845 ops/sec ±0.93% (92 runs sampled)
Fastest is FastIntegerCompression.compress
FastIntegerCompression.uncompress x 187,694 ops/sec ±0.72% (93 runs sampled)
Fastest is FastIntegerCompression.uncompress
```

These numbers means that we can uncompress 187,694 1000-integer arrays per second.
That's 187 millions of integers per second.

## You might also like...

If you like this library, you might also like 
- https://github.com/lemire/FastPriorityQueue.js
- https://github.com/lemire/StablePriorityQueue.js
- https://github.com/lemire/FastBitSet.js

---
_Source: https://npm.io/package/fastintcompression · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
