Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b2f7ee

Browse filesBrowse files
LiviaMedeirosdanielleadams
authored andcommitted
lib: use kEmptyObject in various places
PR-URL: #43159 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 44b65d0 commit 3b2f7ee
Copy full SHA for 3b2f7ee

File tree

Expand file treeCollapse file tree

4 files changed

+11
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+11
-7
lines changed
Open diff view settings
Collapse file

‎lib/internal/blob.js‎

Copy file name to clipboardExpand all lines: lib/internal/blob.js
+2-1Lines 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') {
Collapse file

‎lib/internal/encoding.js‎

Copy file name to clipboardExpand all lines: lib/internal/encoding.js
+5-4Lines changed: 5 additions & 4 deletions
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);
Collapse file

‎lib/internal/histogram.js‎

Copy file name to clipboardExpand all lines: lib/internal/histogram.js
+2-1Lines 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,
Collapse file

‎lib/internal/promise_hooks.js‎

Copy file name to clipboardExpand all lines: lib/internal/promise_hooks.js
+2-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.