Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremiah-shaulov/deno-crc32hash
Calculate crc32 hash of a string, Uint8Array, or Deno.Reader.
https://github.com/jeremiah-shaulov/deno-crc32hash
Last synced: about 2 months ago
JSON representation
Calculate crc32 hash of a string, Uint8Array, or Deno.Reader.
- Host: GitHub
- URL: https://github.com/jeremiah-shaulov/deno-crc32hash
- Owner: jeremiah-shaulov
- License: mit
- Created: 2021-12-26T19:19:38.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-07T05:35:08.000Z (about 2 months ago)
- Last Synced: 2024-11-07T06:27:10.695Z (about 2 months ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crc32hash
[Documentation Index](generated-doc/README.md)
Deno module to calculate crc32 hash of a string, Uint8Array or ReadableStream.
This module exports 2 functions and 1 class:
> `function` [crc32](generated-doc/function.crc32/README.md)(data: `string` | Uint8Array): `number`
> `function` [crc32Stream](generated-doc/function.crc32Stream/README.md)(stream: ReadableStream\, bufferSize: `number`=8\*1024): Promise\<`number`>
> `class` Crc32
> {
> 📄 `get` [value](generated-doc/class.Crc32/README.md#-get-value-number)(): `number`
> ⚙ [update](generated-doc/class.Crc32/README.md#-updatedatapart-string--uint8array-void)(dataPart: `string` | Uint8Array): `void`
> ⚙ [valueOf](generated-doc/class.Crc32/README.md#-valueof-number)(): `number`
> ⚙ [toString](generated-doc/class.Crc32/README.md#-tostring-string)(): `string`
> }#### String:
```ts
import {crc32} from 'https://deno.land/x/[email protected]/mod.ts';console.log(crc32('abc'));
```#### Uint8Array:
```ts
import {crc32} from 'https://deno.land/x/[email protected]/mod.ts';console.log(crc32(new Uint8Array([97, 98, 99])));
```#### ReadableStream:
```ts
import {crc32Stream} from 'https://deno.land/x/[email protected]/mod.ts';const fileUrl = new URL(import.meta.url);
using fp = await Deno.open(fileUrl, {read: true});
console.log(await crc32Stream(fp.readable));
```#### Data parts
```ts
import {crc32, Crc32} from 'https://deno.land/x/[email protected]/mod.ts';
import {assertEquals} from 'jsr:@std/[email protected]/equals';const crc = new Crc32;
crc.update('Lorem ipsum ');
assertEquals(crc.value, crc32('Lorem ipsum '));crc.update('dolor sit amet');
assertEquals(crc.value, crc32('Lorem ipsum dolor sit amet'));
```