fertig-classic-games/src/games/othello/OthelloWorker.js

12 lines
391 B
JavaScript

// OthelloWorker.js: the module worker the kissa's engine runs in.
// See OthelloEngine.js for the message kinds.
import { handle } from './OthelloEngine.js';
self.onmessage = (e) => {
const { id, kind, payload } = e.data ?? {};
let res = null, err = null;
try { res = handle(kind, payload); } catch (ex) { err = String(ex?.message ?? ex); }
self.postMessage({ id, res, err });
};