https://github.com/takker99/crc
tiny tree-shakable CRC implementations for Deno/Browser
https://github.com/takker99/crc
crc crc32 deno
Last synced: 3 months ago
JSON representation
tiny tree-shakable CRC implementations for Deno/Browser
- Host: GitHub
- URL: https://github.com/takker99/crc
- Owner: takker99
- License: mit
- Created: 2024-08-22T23:30:10.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-01-23T02:08:04.000Z (5 months ago)
- Last Synced: 2025-04-10T23:13:24.946Z (3 months ago)
- Topics: crc, crc32, deno
- Language: TypeScript
- Homepage: https://jsr.io/@takker/crc
- Size: 20.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crc
[](https://jsr.io/@takker/crc)
[](https://github.com/takker99/crc/actions?query=workflow%3Aci)tiny tree-shakable CRC implementations for Deno/Browser
# Features
- Written in TypeScript
- Tree-shakable
- Pure implementation, so it works in Deno and Browser## Supported CRC algorithms
Currently, only CRC32 is supported.
# Usage
Calculate CRC32 of a string:
```ts
import { crc32 } from "@takker/crc";
import { assertEquals } from "@std/assert";assertEquals(crc32(new TextEncoder().encode("hello")), 0x3610a686);
```You can also calculate incrementally:
```ts
import { crc32 } from "@takker/crc";
import { assertEquals } from "@std/assert";let checksum = crc32(new TextEncoder().encode("he"));
checksum = crc32(new TextEncoder().encode("ll"), checksum);
checksum = crc32(new TextEncoder().encode("o"), checksum);
assertEquals(checksum, 0x3610a686);
```# Acknowledgements
The implementation of `crc32()` is based on the
[crc32 implementation in fflate](https://github.com/101arrowz/fflate), created
by [@101arrowz](https://github.com/101arrowz).# License
This project is licensed under the [MIT License](LICENSE).
License for fflate is listed in [LICENSE-fflate](LICENSE-fflate).