Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add structuredClone global method #39759

Prev Previous commit
Next Next commit
code fixes
Ethan-Arrowood committed Aug 13, 2021

Verified

This commit was signed with the committer’s verified signature.
codebytere Shelley Vohr
commit ea273ce80c6473ae314eb98e4030d0c205aa1fcb
8 changes: 6 additions & 2 deletions lib/internal/structured_clone.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
'use strict';

const { MessageChannel, receiveMessageOnPort } = require('internal/worker/io');
const {
MessageChannel,
receiveMessageOnPort
} = require('internal/worker/io');


function structuredClone(value, transfer) {
// TODO: Improve this with a more efficient solution that avoids instantiating a MessageChannel
const channel = new MessageChannel();
channel.port1.unref();
channel.port2.unref();
@@ -13,4 +17,4 @@ function structuredClone(value, transfer) {

module.exports = {
structuredClone
}
}