aboutsummaryrefslogtreecommitdiff
path: root/examples/hashing.js
diff options
context:
space:
mode:
authorGravatar Jarred SUmner <jarred@jarredsumner.com> 2022-04-06 01:52:15 -0700
committerGravatar Jarred SUmner <jarred@jarredsumner.com> 2022-04-06 01:53:05 -0700
commit81eb47de0eb08081ed0677b71aa47e9a2b473cab (patch)
tree051df34c66832ab2f0986370d5c8fbb3e12058fc /examples/hashing.js
parent57cf035a73187439fbcd8703d7f4358463ee8314 (diff)
downloadbun-81eb47de0eb08081ed0677b71aa47e9a2b473cab.tar.gz
bun-81eb47de0eb08081ed0677b71aa47e9a2b473cab.tar.zst
bun-81eb47de0eb08081ed0677b71aa47e9a2b473cab.zip
[bun.js] Add stdout, stderr, stdin to Bun and support sendfile() + splice()
Diffstat (limited to 'examples/hashing.js')
-rw-r--r--examples/hashing.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/hashing.js b/examples/hashing.js
new file mode 100644
index 000000000..cf4772ffe
--- /dev/null
+++ b/examples/hashing.js
@@ -0,0 +1,18 @@
+// Accepts a string, TypedArray, or Blob (file blob supported 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));
+
+// Second argument accepts a seed where relevant
+console.log(Bun.hash(input, 12345));