Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reuse messagechannel and lazily instantiate
  • Loading branch information
Ethan-Arrowood committed Aug 13, 2021
commit 784c169b8ff763b9d4bca2b0039079f378f757ac
6 changes: 4 additions & 2 deletions lib/internal/structured_clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ const {
receiveMessageOnPort
Comment thread
Ethan-Arrowood marked this conversation as resolved.
Outdated
} = require('internal/worker/io');


let channel
Comment thread
Ethan-Arrowood marked this conversation as resolved.
Outdated
function structuredClone(value, transfer) {
// TODO: Improve this with a more efficient solution that avoids instantiating a MessageChannel
Comment thread
Ethan-Arrowood marked this conversation as resolved.
Outdated
const channel = new MessageChannel();
if (!channel) {
channel = new MessageChannel();
}
Comment thread
Ethan-Arrowood marked this conversation as resolved.
Outdated
Comment thread
Ethan-Arrowood marked this conversation as resolved.
Outdated
channel.port1.unref();
channel.port2.unref();
channel.port1.postMessage(value, transfer);
Expand Down