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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.