worker: use kEmptyObject

PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
LiviaMedeiros
2022-05-21 17:57:56 +08:00
committed by Antoine du Hamel
parent 51e7f751c7
commit b1c1f86389
2 changed files with 7 additions and 3 deletions

View File

@@ -55,6 +55,7 @@ const {
} = workerIo;
const { deserializeError } = require('internal/error_serdes');
const { fileURLToPath, isURLInstance, pathToFileURL } = require('internal/url');
const { kEmptyObject } = require('internal/util');
const { validateArray } = require('internal/validators');
const {
@@ -118,7 +119,7 @@ function assignEnvironmentData(data) {
}
class Worker extends EventEmitter {
constructor(filename, options = {}) {
constructor(filename, options = kEmptyObject) {
super();
debug(`[${threadId}] create new worker`, filename, options);
if (options.execArgv)

View File

@@ -18,7 +18,10 @@ const {
SymbolFor,
} = primordials;
const { kEnumerableProperty } = require('internal/util');
const {
kEmptyObject,
kEnumerableProperty,
} = require('internal/util');
const {
handle_onclose: handleOnCloseSymbol,
@@ -123,7 +126,7 @@ class MessageEvent extends Event {
lastEventId = '',
source = null,
ports = [],
} = {}) {
} = kEmptyObject) {
super(type);
this[kData] = data;
this[kOrigin] = `${origin}`;