From 4e87195739f2a5d9a05451b48773c8afdc680765 Mon Sep 17 00:00:00 2001 From: akiyamn Date: Sun, 24 Sep 2023 23:22:21 +1000 Subject: Initial commit (by create-cloudflare CLI) --- .../blake3-wasm/esm/node-native/hash-instance.js | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 node_modules/blake3-wasm/esm/node-native/hash-instance.js (limited to 'node_modules/blake3-wasm/esm/node-native/hash-instance.js') diff --git a/node_modules/blake3-wasm/esm/node-native/hash-instance.js b/node_modules/blake3-wasm/esm/node-native/hash-instance.js new file mode 100644 index 0000000..86da52d --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-instance.js @@ -0,0 +1,26 @@ +import native from './native.js'; +import { NodeHash } from '../node/hash-instance.js'; +import { NodeHashReader } from '../node/hash-reader.js'; +// A buffer we reuse for sending bigints. set_position is synchronous, so +// this just saves creating garbage. +const bigIntBuffer = Buffer.alloc(8); +const readerFactory = (r) => new NodeHashReader({ + fill: target => r.fill(target), + set_position: position => { + bigIntBuffer.writeBigUInt64BE(position); + r.set_position(bigIntBuffer); + }, +}); +/** + * A Node.js crypto-like createHash method. + */ +export const createHash = () => new NodeHash(new native.Hasher(), readerFactory); +/** + * Construct a new Hasher for the keyed hash function. + */ +export const createKeyed = (key) => new NodeHash(new native.Hasher(key), readerFactory); +/** + * Construct a new Hasher for the key derivation function. + */ +export const createDeriveKey = (context) => new NodeHash(new native.Hasher(undefined, context), readerFactory); +//# sourceMappingURL=hash-instance.js.map \ No newline at end of file -- cgit v1.2.3