Skip to content

Commit ae13f10

Browse files
committed
lib: use kEmptyObject in various places
1 parent 8b5c1e9 commit ae13f10

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

lib/internal/blob.js

Lines changed: 2 additions & 1 deletion
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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const kEncoder = Symbol('encoder');
3131
const {
3232
getConstructorOf,
3333
customInspectSymbol: inspect,
34+
kEmptyObject,
3435
kEnumerableProperty,
3536
} = require('internal/util');
3637

@@ -377,7 +378,7 @@ function makeTextDecoderICU() {
377378
} = internalBinding('icu');
378379

379380
class TextDecoder {
380-
constructor(encoding = 'utf-8', options = {}) {
381+
constructor(encoding = 'utf-8', options = kEmptyObject) {
381382
encoding = `${encoding}`;
382383
validateObject(options, 'options', {
383384
nullable: true,
@@ -406,7 +407,7 @@ function makeTextDecoderICU() {
406407
}
407408

408409

409-
decode(input = empty, options = {}) {
410+
decode(input = empty, options = kEmptyObject) {
410411
validateDecoder(this);
411412
if (isAnyArrayBuffer(input)) {
412413
input = lazyBuffer().from(input);
@@ -451,7 +452,7 @@ function makeTextDecoderJS() {
451452
}
452453

453454
class TextDecoder {
454-
constructor(encoding = 'utf-8', options = {}) {
455+
constructor(encoding = 'utf-8', options = kEmptyObject) {
455456
encoding = `${encoding}`;
456457
validateObject(options, 'options', {
457458
nullable: true,
@@ -479,7 +480,7 @@ function makeTextDecoderJS() {
479480
this[kBOMSeen] = false;
480481
}
481482

482-
decode(input = empty, options = {}) {
483+
decode(input = empty, options = kEmptyObject) {
483484
validateDecoder(this);
484485
if (isAnyArrayBuffer(input)) {
485486
input = lazyBuffer().from(input);

lib/internal/histogram.js

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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)