-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
43 lines (41 loc) · 1.31 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
/**
* Calculates the required size of the filter in bits
* ```rust
* filter_size = - (item_count * lg(false_positive_rate)) / (lg(2)^2)
* ```
*/
export function calculateFilterSize(itemCount: number, falsePositiveRate: number): number
/**
* Calculates the optimal number of hash functions to use
* ```rust
* hash_fns_required = (bits / item_count) * ln(2)
* ```
*/
export function calculateRequiredHashFunctions(bits: bigint, itemsCount: number): number
export class Zoomies {
/**
* Create a new bloom filter with the given number of items and false positive rate
* ```rust
* let bloom_filter = BloomFilter::new(100, 0.01); // 100 items, 1% false positive rate
* ```
*/
constructor(itemCount: number, falsePositiveRate: number)
static newFromCompiledFilter(bitFilter: Buffer, hashFns: number): Zoomies
/** Insert an address into the filter */
insertAddress(item: string): void
/**
* Query the filter for an address
* ```ts
* const bloomFilter = new Zoomies(100, 0.01);
* bloomFilter.insertAddress('0x1234');
* bloomFilter.queryAddress('0x1234'); // true
* bloomFilter.queryAddress('0x5678'); // false
* ```
*/
queryAddress(item: string): boolean
extractCompiledFilter(): Buffer
getHashFns(): number
}