• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4
5const { MessageChannel } = require('worker_threads');
6
7{
8  const { port1, port2 } = new MessageChannel();
9
10  const arrayBuffer = new ArrayBuffer(40);
11  const typedArray = new Uint32Array(arrayBuffer);
12  typedArray[0] = 0x12345678;
13
14  port1.postMessage(typedArray, [ arrayBuffer ]);
15  port2.on('message', common.mustCall((received) => {
16    assert.strictEqual(received[0], 0x12345678);
17    port2.close(common.mustCall());
18  }));
19}
20