npm.io
0.3.1 • Published 2h ago

@hugoalh/djb2a

Licence
MIT
Version
0.3.1
Deps
1
Size
10 kB
Vulns
0
Weekly
0
Stars
1

DJB2a (ES)

MIT

DistBoard @hugoalhGitHubJSRNPM

An ECMAScript module to get the non-cryptographic hash of the data with algorithm DJB2a (32 bits).

Runtime Targets

Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:

Runtime Permissions

This does not request any runtime permission.

Sources & Entrypoints

  • GitHub Raw
    https://raw.githubusercontent.com/hugoalh/djb2a-es/{Tag}/mod.ts
  • JSR
    jsr:@hugoalh/djb2a[@{Tag}]
  • NPM
    npm:@hugoalh/djb2a[@{Tag}]
Name Path Description
. ./mod.ts Default.

  • 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

  • class DJB2a {
      constructor(data?: DJB2aAcceptDataType);
      get freezed(): boolean;
      freeze(): this;
      hash(): Uint8Array;
      hashHex(): string;
      update(data: DJB2aAcceptDataType): this;
      updateFromStream(stream: ReadableStream<DJB2aAcceptDataType>): Promise<this>;
    }
  • type DJB2aAcceptDataType =
      | string
      | BigUint64Array
      | Uint8Array
      | Uint16Array
      | Uint32Array;

Examples

  • new DJB2a("hello").hashHex();
    //=> "0A9CEDE7"

Keywords