use worker to avoid freezing

This commit is contained in:
filifa
2025-12-11 23:49:34 -05:00
parent 6175224c9b
commit fcdf795387
3 changed files with 19 additions and 14 deletions

View File

@@ -14,7 +14,17 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { modinv, modpow, modsqrt, ord } from "./math.js";
importScripts("./math.js")
addEventListener("message", (message) => {
if (message.data.command === "compute") {
try {
compute(message.data.queue, message.data.m);
} catch(e) {
postMessage(e);
}
}
});
function binaryOpPop(stack) {
const b = stack.pop();
@@ -88,7 +98,5 @@ function compute(queue, modulus) {
result += modulus;
}
return result;
postMessage(result);
}
export { compute };

View File

@@ -220,5 +220,3 @@ function ord(n, modulus) {
return k;
}
export { modsqrt, modinv, modpow, ord };