()
| 5 | let xxh3Cache: Xxh3Module | null = null; |
| 6 | |
| 7 | async function getXxh3(): Promise<Xxh3Module> { |
| 8 | if (!xxh3Cache) { |
| 9 | try { |
| 10 | const module = await import('@node-rs/xxhash'); |
| 11 | xxh3Cache = module.xxh3; |
| 12 | } catch { |
| 13 | throw new Error( |
| 14 | 'The "digest" function requires the "@node-rs/xxhash" package, but it was not found.' |
| 15 | ); |
| 16 | } |
| 17 | } |
| 18 | return xxh3Cache; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Computes a deterministic 64-bit XXH3 digest of the input. |