aboutsummaryrefslogtreecommitdiff
path: root/examples/hashing.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hashing.js')
-rw-r--r--examples/hashing.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/examples/hashing.js b/examples/hashing.js
index cf4772ffe..3f23d1312 100644
--- a/examples/hashing.js
+++ b/examples/hashing.js
@@ -1,18 +1,19 @@
-// Accepts a string, TypedArray, or Blob (file blob supported is not implemented but planned)
+// Accepts a string, TypedArray, or Blob (file blob support is not implemented but planned)
const input = "hello world".repeat(400);
// Bun.hash() defaults to Wyhash because it's fast
console.log(Bun.hash(input));
console.log(Bun.hash.wyhash(input));
-// and returns a number
-// all of these hashing functions return numbers, not typed arrays.
-console.log(Bun.hash.adler32(input));
-console.log(Bun.hash.crc32(input));
-console.log(Bun.hash.cityHash32(input));
-console.log(Bun.hash.cityHash64(input));
-console.log(Bun.hash.murmur32v3(input));
-console.log(Bun.hash.murmur64v2(input));
+// and returns a bigint
+// all of these hashing functions return number if 32-bit or bigint if 64-bit, not typed arrays.
+console.log(Bun.hash.adler32(input)); // number
+console.log(Bun.hash.crc32(input)); // number
+console.log(Bun.hash.cityHash32(input)); // number
+console.log(Bun.hash.cityHash64(input)); // bigint
+console.log(Bun.hash.murmur32v3(input)); // number
+console.log(Bun.hash.murmur32v2(input)); // number
+console.log(Bun.hash.murmur64v2(input)); // bigint
// Second argument accepts a seed where relevant
console.log(Bun.hash(input, 12345));