Skip to content

Commit

Permalink
lib: make structuredClone spec compliant
Browse files Browse the repository at this point in the history
Fixes: #40246

PR-URL: #40251
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
VoltrexKeyva authored and nodejs-github-bot committed Oct 3, 2021
1 parent 6199441 commit 3d11baf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/internal/structured_clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const {
} = require('internal/worker/io');

let channel;
function structuredClone(value, transfer) {
function structuredClone(value, options = undefined) {
// 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, transfer);
channel.port1.postMessage(value, options?.transfer);
return receiveMessageOnPort(channel.port2).message;
}

Expand Down

0 comments on commit 3d11baf

Please sign in to comment.