UNPKG

stockfish

Version:

The Stockfish chess engine in Web Assembly (WASM)

17 lines (14 loc) 355 B
// // Patch `onmessage` to support custom message // const old_onmessage = self.onmessage; const new_onmessage = (e) => { if (e.data.cmd === 'custom') { if (typeof Module['onCustomMessage'] === 'function') { Module['onCustomMessage'](e.data.userData); } } else { old_onmessage(e); } } onmessage = self.onmessage = new_onmessage;