Skip to content

Commit 3b2f7ee

Browse files
LiviaMedeirosdanielleadams
authored andcommitted
lib: use kEmptyObject in various places
PR-URL: #43159 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 44b65d0 commit 3b2f7ee

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

lib/internal/blob.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const {
4444
const {
4545
createDeferredPromise,
4646
customInspectSymbol: kInspect,
47+
kEmptyObject,
4748
} = require('internal/util');
4849
const { inspect } = require('internal/util/inspect');
4950

@@ -134,7 +135,7 @@ class Blob {
134135
* }} [options]
135136
* @constructs {Blob}
136137
*/
137-
constructor(sources = [], options = {}) {
138+
constructor(sources = [], options = kEmptyObject) {
138139
if (sources === null ||
139140
typeof sources[SymbolIterator] !== 'function' ||
140141
typeof sources === 'string') {

lib/internal/encoding.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const kEncoder = Symbol('encoder');
3333
const {
3434
getConstructorOf,
3535
customInspectSymbol: inspect,
36+
kEmptyObject,
3637
kEnumerableProperty,
3738
} = require('internal/util');
3839

@@ -379,7 +380,7 @@ function makeTextDecoderICU() {
379380
} = internalBinding('icu');
380381

381382
class TextDecoder {
382-
constructor(encoding = 'utf-8', options = {}) {
383+
constructor(encoding = 'utf-8', options = kEmptyObject) {
383384
encoding = `${encoding}`;
384385
validateObject(options, 'options', {
385386
nullable: true,
@@ -408,7 +409,7 @@ function makeTextDecoderICU() {
408409
}
409410

410411

411-
decode(input = empty, options = {}) {
412+
decode(input = empty, options = kEmptyObject) {
412413
validateDecoder(this);
413414
if (isAnyArrayBuffer(input)) {
414415
input = lazyBuffer().from(input);
@@ -453,7 +454,7 @@ function makeTextDecoderJS() {
453454
}
454455

455456
class TextDecoder {
456-
constructor(encoding = 'utf-8', options = {}) {
457+
constructor(encoding = 'utf-8', options = kEmptyObject) {
457458
encoding = `${encoding}`;
458459
validateObject(options, 'options', {
459460
nullable: true,
@@ -481,7 +482,7 @@ function makeTextDecoderJS() {
481482
this[kBOMSeen] = false;
482483
}
483484

484-
decode(input = empty, options = {}) {
485+
decode(input = empty, options = kEmptyObject) {
485486
validateDecoder(this);
486487
if (isAnyArrayBuffer(input)) {
487488
input = lazyBuffer().from(input);

lib/internal/histogram.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717

1818
const {
1919
customInspectSymbol: kInspect,
20+
kEmptyObject,
2021
} = require('internal/util');
2122

2223
const { inspect } = require('util');
@@ -352,7 +353,7 @@ internalRecordableHistogram.prototype[kDeserialize] = () => {};
352353
* }} [options]
353354
* @returns {RecordableHistogram}
354355
*/
355-
function createHistogram(options = {}) {
356+
function createHistogram(options = kEmptyObject) {
356357
validateObject(options, 'options');
357358
const {
358359
lowest = 1,

lib/internal/promise_hooks.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
const { setPromiseHooks } = internalBinding('async_wrap');
1212
const { triggerUncaughtException } = internalBinding('errors');
1313

14+
const { kEmptyObject } = require('internal/util');
1415
const { validatePlainFunction } = require('internal/validators');
1516

1617
const hooks = {
@@ -101,7 +102,7 @@ const onBefore = makeUseHook('before');
101102
const onAfter = makeUseHook('after');
102103
const onSettled = makeUseHook('settled');
103104

104-
function createHook({ init, before, after, settled } = {}) {
105+
function createHook({ init, before, after, settled } = kEmptyObject) {
105106
const hooks = [];
106107

107108
if (init) ArrayPrototypePush(hooks, onInit(init));

0 commit comments

Comments
 (0)