mirror of
https://github.com/keven1024/015.git
synced 2026-06-09 22:04:34 +00:00
feat(front): implement engine detection for file hash calculation and add error handling for unsupported environments
This commit is contained in:
@@ -35,4 +35,15 @@ export const calcNativeHash = async (buffer: BufferSource) => {
|
||||
.join('')
|
||||
}
|
||||
|
||||
export const detectSupportedEngines = (): ('native' | 'wasm')[] => {
|
||||
const engines: ('native' | 'wasm')[] = []
|
||||
if (typeof crypto !== 'undefined' && typeof crypto.subtle !== 'undefined') {
|
||||
engines.push('native')
|
||||
}
|
||||
if (typeof WebAssembly !== 'undefined' && typeof WebAssembly.instantiate === 'function') {
|
||||
engines.push('wasm')
|
||||
}
|
||||
return engines
|
||||
}
|
||||
|
||||
export default calcFileHash
|
||||
|
||||
Reference in New Issue
Block a user