UNPKG

2.69 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/imurmurhash`
3
4# Summary
5This package contains type definitions for imurmurhash (https://github.com/jensyt/imurmurhash-js).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/imurmurhash.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/imurmurhash/index.d.ts)
10````ts
11/**
12 * An incremental implementation of MurmurHash3 for JavaScript
13 */
14interface MurmurHash3 {
15 /**
16 * Get the result of the hash as a 32-bit positive integer.
17 * This performs the tail and finalizer portions of the algorithm, but does not store the result in the state object.
18 * This means that it is perfectly safe to get results and then continue adding strings via hash.
19 */
20 result(): number;
21
22 /**
23 * Reset the state object for reuse, optionally using the given seed (defaults to 0 like the constructor). Returns this so calls can be chained.
24 * @default 0
25 */
26 reset(seed?: number): this;
27
28 /**
29 * Incrementally add string to the hash.
30 * This can be called as many times as you want for the hash state object, including after a call to result()
31 */
32 hash(value: string): this;
33}
34declare var MurmurHash3: {
35 /**
36 * Get a hash state object, optionally initialized with the given string and seed.
37 * Seed must be a positive integer if provided.
38 * Calling this function without the new keyword will return a cached state object that has been reset.
39 * This is safe to use as long as the object is only used from a single thread and no other hashes are created while operating on this one.
40 * If this constraint cannot be met, you can use new to create a new state object
41 */
42 (text?: string, seed?: number): MurmurHash3;
43 /**
44 * Get a hash state object, optionally initialized with the given string and seed.
45 * Seed must be a positive integer if provided.
46 * Calling this function without the new keyword will return a cached state object that has been reset.
47 * This is safe to use as long as the object is only used from a single thread and no other hashes are created while operating on this one.
48 * If this constraint cannot be met, you can use new to create a new state object
49 */
50 new(text?: string, seed?: number): MurmurHash3;
51};
52
53export as namespace MurmurHash3;
54export = MurmurHash3;
55
56````
57
58### Additional Details
59 * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
60 * Dependencies: none
61
62# Credits
63These definitions were written by [Jiayu Liu](https://github.com/Jimexist), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).
64
\No newline at end of file