mirror of
https://github.com/xtr-dev/rondevu-server.git
synced 2025-12-10 10:53:24 +00:00
Fix: Replace Buffer with atob for Cloudflare Workers
Buffer is not available in Workers environment. Use atob() for base64 decoding which works in both Node.js and Workers. Fixes ReferenceError: Buffer is not defined 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
10
src/bloom.ts
10
src/bloom.ts
@@ -12,9 +12,13 @@ export class BloomFilter {
|
|||||||
* Creates a bloom filter from a base64 encoded bit array
|
* Creates a bloom filter from a base64 encoded bit array
|
||||||
*/
|
*/
|
||||||
constructor(base64Data: string, numHashes: number = 3) {
|
constructor(base64Data: string, numHashes: number = 3) {
|
||||||
// Decode base64 to buffer
|
// Decode base64 to Uint8Array (works in both Node.js and Workers)
|
||||||
const buffer = Buffer.from(base64Data, 'base64');
|
const binaryString = atob(base64Data);
|
||||||
this.bits = new Uint8Array(buffer);
|
const bytes = new Uint8Array(binaryString.length);
|
||||||
|
for (let i = 0; i < binaryString.length; i++) {
|
||||||
|
bytes[i] = binaryString.charCodeAt(i);
|
||||||
|
}
|
||||||
|
this.bits = bytes;
|
||||||
this.size = this.bits.length * 8;
|
this.size = this.bits.length * 8;
|
||||||
this.numHashes = numHashes;
|
this.numHashes = numHashes;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user