I created a function that allows you to create and store a new PoW at the start of the application and each time you spend the old PoW and need a new one. This saves some time for the end user because generating a PoW can take some time. It is not finished, and not perfect, but I do want to share it with you.
setTimeout(() => {
generatePow(secrateKey);
}, 1000);
var pow = null;
async function generatePow(secretKey) {
var address = await secretKeytoaddr(secretKey);
var sddsf_address = await accountdig(address);
var previous = sddsf_address.frontier;
console.log("generating PoW")
pow = await hybirdWork(previous);
console.log("PoW ready");
}
async function send(secretKey, sendto, amount) {
if(pow == null){
console.log("PoW not ready yet")
return;
}
...
generatePow(secretKey);
return retr;
}