https://github.com/thibmeu/quicvarint
Variable-Length Integer Encoding defined by RFC 9000
https://github.com/thibmeu/quicvarint
2msb cryptography rfc9000 typescript varint
Last synced: 4 months ago
JSON representation
Variable-Length Integer Encoding defined by RFC 9000
- Host: GitHub
- URL: https://github.com/thibmeu/quicvarint
- Owner: thibmeu
- License: mit
- Created: 2025-02-28T16:09:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-05T09:49:05.000Z (over 1 year ago)
- Last Synced: 2025-10-20T10:59:08.640Z (8 months ago)
- Topics: 2msb, cryptography, rfc9000, typescript, varint
- Language: TypeScript
- Homepage:
- Size: 150 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# quicvarint

[][npm]
[npm]: https://www.npmjs.com/package/quicvarint
Variable-Length Integer Encoding defined by [RFC 9000](https://www.rfc-editor.org/rfc/rfc9000.html#name-variable-length-integer-enc).
## Tables of Content
* [Features](#features)
* [Usage](#usage)
* [Security Considerations](#security-considerations)
* [License](#license)
## Features
* Decode a 2-MSB varint from a DataView or a Uint8Array
* Encode a 2-MSB varint to a Uint8Array
* Support integer between 0 and 2147483647 included
* TypeScript types
## Usage
```typescript
import { encode, decode, MAX } from "quicvarint"
// A number between 0 and MAX
const n = 1234
// Encode it to a Uint8Array
const encN = encode(n)
// Decode it and print it on console
console.log(decode(encN))
```
## Security Considerations
This software has not been audited. Please use at your sole discretion.
## License
This project is under the MIT license.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be MIT licensed as above, without any additional terms or conditions.