Skip to content
Closed
Show file tree
Hide file tree
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
nits
  • Loading branch information
Ethan-Arrowood committed Aug 13, 2021
commit d0dedb00b10b029e34af2b1cbe20d5a3fe1cd22d
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,6 @@ module.exports = {
btoa: 'readable',
atob: 'readable',
performance: 'readable',
structuredClone: 'readable'
structuredClone: 'readable',
},
};
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ if (!config.noBrowserGlobals) {
defineOperation(globalThis, 'setImmediate', timers.setImmediate);

const {
structuredClone
structuredClone,
} = require('internal/structured_clone');
defineOperation(globalThis, 'structuredClone', structuredClone);
}
Expand Down
6 changes: 2 additions & 4 deletions lib/internal/structured_clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

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

let channel;
function structuredClone(value, transfer) {
// TODO: Improve this with a more efficient solution that avoids
// instantiating a MessageChannel
if (!channel) {
channel = new MessageChannel();
}
channel ??= new MessageChannel();
channel.port1.unref();
channel.port2.unref();
channel.port1.postMessage(value, transfer);
Expand Down