Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takker99/crc
tiny tree-shakable CRC implementations for Deno/Browser
https://github.com/takker99/crc
crc crc32 deno
Last synced: about 1 month 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 (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-26T21:54:27.000Z (about 2 months ago)
- Last Synced: 2024-09-30T18:40:55.224Z (about 2 months ago)
- Topics: crc, crc32, deno
- Language: TypeScript
- Homepage: https://jsr.io/@takker/crc
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crc
[![JSR](https://jsr.io/badges/@takker/crc)](https://jsr.io/@takker/crc)
[![test](https://github.com/takker99/crc/workflows/ci/badge.svg)](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).