Skip to content

Commit e3d8cdc

Browse files
committed
comment on mask param
1 parent aa44db2 commit e3d8cdc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/gearhash-wasm/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import { nextMatch } from '@huggingface/gearhash-wasm';
1111
const data = new Uint8Array(1000000); // Example: 1MB of data
1212
// ... fill data with your content ...
1313

14-
const mask = 0x0000d90003530000n; // Example mask as a BigInt, more 0s => bigger chunks
14+
const mask = 0x0000d90003530000n; // Example mask as a BigInt, more 1s in binary repr => bigger chunks
15+
//^ it has 11 1s in binary, so chunks will be ~2048 long
1516
const match = nextMatch(data, mask);
1617
const allMatches = nextMatches(data, mask).matches;
1718
```
1819

1920
The `nextMatch` function takes two parameters:
2021
- `data`: A Uint8Array containing the data to search through
21-
- `mask`: A BigInt, the bigger it is the bigger the chunks are
22+
- `mask`: A BigInt, the more 1s it has in its binary representation, the bigger the chunk
2223

2324
The function returns an object with the `position` (i32) and `hash` (u64) properties
2425

@@ -81,3 +82,4 @@ console.log(length, "bytes without a match, ending hash: ", hash);
8182

8283
## Possible improvements
8384

85+
SIMD

0 commit comments

Comments
 (0)