0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/parallel/test-v8-serdes-sharedarraybuffer.js
Weijia Wang 254058109f tools: add 'spaced-comment' into eslint rules
PR-URL: https://github.com/nodejs/node/pull/19596
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-04-01 22:33:13 +08:00

27 lines
627 B
JavaScript

/* global SharedArrayBuffer */
'use strict';
const common = require('../common');
const assert = require('assert');
const v8 = require('v8');
{
const sab = new SharedArrayBuffer(64);
const uint8array = new Uint8Array(sab);
const ID = 42;
const ser = new v8.Serializer();
ser._getSharedArrayBufferId = common.mustCall(() => ID);
ser.writeHeader();
ser.writeValue(uint8array);
const des = new v8.Deserializer(ser.releaseBuffer());
des.readHeader();
des.transferArrayBuffer(ID, sab);
const value = des.readValue();
assert.strictEqual(value.buffer, sab);
assert.notStrictEqual(value, uint8array);
}