Skip to content

Commit

Permalink
Implement createFastHash for Bun
Browse files Browse the repository at this point in the history
In Bun builds, createFastHash uses Bun.hash. See: https://bun.sh/docs/api/hashing#bun-hash
  • Loading branch information
acdlite committed Sep 20, 2023
1 parent 531b4f1 commit 630ac4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-server/src/ReactServerStreamConfigBun.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @flow
*/

/* global Bun */

type BunReadableStreamController = ReadableStreamController & {
end(): mixed,
write(data: Chunk | BinaryChunk): void,
Expand Down Expand Up @@ -98,5 +100,5 @@ export function closeWithError(destination: Destination, error: mixed): void {
}

export function createFastHash(input: string): string | number {
return input;
return Bun.hash(input);
}
6 changes: 6 additions & 0 deletions scripts/flow/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,9 @@ declare module 'node:worker_threads' {
port2: MessagePort;
}
}

declare var Bun: {
hash(
input: string | $TypedArray | DataView | ArrayBuffer | SharedArrayBuffer,
): number,
};

0 comments on commit 630ac4e

Please sign in to comment.