Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 21x 21x 1x 1x 20x 20x 20x 20x 20x 20x 21x 21x 21x 24x 24x 24x 24x | 'use strict';
const {
codes: { ERR_MISSING_ARGS },
} = require('internal/errors');
const {
MessageChannel,
receiveMessageOnPort,
} = require('internal/worker/io');
let channel;
function structuredClone(value, options = undefined) {
if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('value');
}
// TODO: Improve this with a more efficient solution that avoids
// instantiating a MessageChannel
channel ??= new MessageChannel();
channel.port1.unref();
channel.port2.unref();
channel.port1.postMessage(value, options?.transfer);
return receiveMessageOnPort(channel.port2).message;
}
module.exports = {
structuredClone,
};
|