- Open your command-line application, and navigate to your workspace.
- Create a new folder named 05-06-sending-shared-array-to-worker.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file with an onMessage function that logs out the result and type members of the received message data:
function onMessage(message) { const { result, type } = message.data; console.log('result from worker operation: %s', type, result); }
- Create a main.js file with a main method that defines constants for NUM_COUNT, BYTES_FOR_32_BIT, ARRAY_SIZE, and MAX_NUMBER:
export function main() { const NUM_COUNT = 2048; const BYTES_FOR_32_BIT = 4; const ARRAY_SIZE = NUM_COUNT * BYTES_FOR_32_BIT; const MAX_NUMBER ...