improve sea.work

This commit is contained in:
noname 2025-03-09 00:45:21 +07:00
parent dfb0fb3fca
commit f1bcb612a9

View File

@ -16,8 +16,9 @@
// Check if data is an ArrayBuffer, if so use Uint8Array to access the data
if(data instanceof ArrayBuffer){
data = new Uint8Array(data);
data = new TextDecoder("utf-8").decode(data);
}
data = (typeof data == 'string')? data : await shim.stringify(data);
data = (typeof data == 'string') ? data : await shim.stringify(data);
if('sha' === (opt.name||'').toLowerCase().slice(0,3)){
var rsha = shim.Buffer.from(await sha(data, opt.name), 'binary').toString(opt.encode || 'base64')
if(cb){ try{ cb(rsha) }catch(e){console.log(e)} }