@hugoalh/sdbm
Version:
A module to get the non-cryptographic hash of the data with algorithm SDBM.
85 lines (67 loc) ⢠2.26 kB
Markdown
# SDBM (ES)
[**āļø** MIT](./LICENSE.md)
š
[DistBoard @hugoalh](https://hugoalh.github.io/distboard/sdbm_ecmascript)
ā [GitHub](https://github.com/hugoalh/sdbm-es)
ā [JSR](https://jsr.io/@hugoalh/sdbm)
ā [NPM](https://www.npmjs.com/package/@hugoalh/sdbm)
An ECMAScript module to get the non-cryptographic hash of the data with algorithm SDBM (32 bits).
## šÆ Runtime Targets
Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:
- **[Bun](https://bun.sh/)** >= v1.1.0
- **[Deno](https://deno.land/)** >= v2.1.0
- **[NodeJS](https://nodejs.org/)** >= v20.9.0
## š”ļø Runtime Permissions
This does not request any runtime permission.
## #ļøā£ Sources & Entrypoints
- GitHub Raw
```
https://raw.githubusercontent.com/hugoalh/sdbm-es/{Tag}/mod.ts
```
- JSR
```
jsr:@hugoalh/sdbm[@{Tag}]
```
- NPM
```
npm:@hugoalh/sdbm[@{Tag}]
```
| **Name** | **Path** | **Description** |
|:--|:--|:--|
| `.` | `./mod.ts` | Default. |
> [!NOTE]
> - Different runtimes have vary support for the sources and entrypoints, visit the runtime documentation for more information.
> - It is recommended to include tag for immutability.
> - These are not part of the public APIs hence should not be used:
> - Benchmark/Test file (e.g.: `example.bench.ts`, `example.test.ts`).
> - Entrypoint name or path include any underscore prefix (e.g.: `_example.ts`, `foo/_example.ts`).
> - Identifier/Namespace/Symbol include any underscore prefix (e.g.: `_example`, `Foo._example`).
## š§© APIs
- ```ts
class SDBM {
constructor(data?: SDBMAcceptDataType);
get freezed(): boolean;
freeze(): this;
hash(): Uint8Array;
hashHex(): string;
update(data: SDBMAcceptDataType): this;
updateFromStream(stream: ReadableStream<SDBMAcceptDataType>): Promise<this>;
}
```
- ```ts
type SDBMAcceptDataType =
| string
| BigUint64Array
| Uint8Array
| Uint16Array
| Uint32Array;
```
> [!NOTE]
> - For the full or prettier documentation, can visit via:
> - [Deno CLI `deno doc`](https://docs.deno.com/runtime/reference/cli/doc/)
> - [JSR](https://jsr.io/@hugoalh/sdbm)
## āļø Examples
- ```ts
new SDBM("hello").hashHex();
//=> "28D19932"
```