• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3require('../common');
4const assert = require('assert');
5
6const sab = new SharedArrayBuffer(24);
7const arr1 = new Uint16Array(sab);
8const arr2 = new Uint16Array(12);
9arr2[0] = 5000;
10arr1[0] = 5000;
11arr1[1] = 4000;
12arr2[1] = 4000;
13
14const arr_buf = Buffer.from(arr1.buffer);
15const ar_buf = Buffer.from(arr2.buffer);
16
17assert.deepStrictEqual(arr_buf, ar_buf);
18
19arr1[1] = 6000;
20arr2[1] = 6000;
21
22assert.deepStrictEqual(arr_buf, ar_buf);
23
24// Checks for calling Buffer.byteLength on a SharedArrayBuffer.
25assert.strictEqual(Buffer.byteLength(sab), sab.byteLength);
26
27Buffer.from({ buffer: sab }); // Should not throw.
28