How to do it...

  1. Open your command-line application and navigate to your workspace.
  2. Create a new folder named 05-07-reading-shared-buffer-from-multiple-workers.
  3. Copy or create an index.html that loads and runs a main function from main.js.
  4. Create a main.js file with an onMessage function that logs out the following members of the message data: workenIndex, type, result, workerIndex, startIndex, endIndex, and windowSize:
// main.jsfunction onMessage(message) {const {     type,     result,     workerIndex,     startIndex,     endIndex,     windowSize   } = message.data;   console.log(`Result from worker operation {     type: ${type},     result: ${result},     workerIndex: ${workerIndex},     startIndex: ${startIndex},     endIndex: ${endIndex},  windowSize: ${windowSize}  ...

Get ECMAScript Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.