diff options
Diffstat (limited to 'node_modules/blake3-wasm/esm/browser/hash-reader.js')
| -rw-r--r-- | node_modules/blake3-wasm/esm/browser/hash-reader.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/node_modules/blake3-wasm/esm/browser/hash-reader.js b/node_modules/blake3-wasm/esm/browser/hash-reader.js new file mode 100644 index 0000000..1843eb0 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-reader.js @@ -0,0 +1,25 @@ +import { BaseHashReader } from '../base/hash-reader.js'; +import { Hash } from './hash.js'; +import { defaultHashLength } from '../base/index.js'; +/** + * A hash reader for WebAssembly targets. + */ +export class BrowserHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toArray().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray() { + this.position = BigInt(0); + return this.read(defaultHashLength); + } + alloc(bytes) { + return new Hash(bytes); + } +} +//# sourceMappingURL=hash-reader.js.map
\ No newline at end of file |
