mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: use kEmptyObject in various places
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:
committed by
Antoine du Hamel
parent
b1c1f86389
commit
917fcb2044
@@ -44,6 +44,7 @@ const {
|
||||
const {
|
||||
createDeferredPromise,
|
||||
customInspectSymbol: kInspect,
|
||||
kEmptyObject,
|
||||
} = require('internal/util');
|
||||
const { inspect } = require('internal/util/inspect');
|
||||
|
||||
@@ -134,7 +135,7 @@ class Blob {
|
||||
* }} [options]
|
||||
* @constructs {Blob}
|
||||
*/
|
||||
constructor(sources = [], options = {}) {
|
||||
constructor(sources = [], options = kEmptyObject) {
|
||||
if (sources === null ||
|
||||
typeof sources[SymbolIterator] !== 'function' ||
|
||||
typeof sources === 'string') {
|
||||
|
||||
@@ -33,6 +33,7 @@ const kEncoder = Symbol('encoder');
|
||||
const {
|
||||
getConstructorOf,
|
||||
customInspectSymbol: inspect,
|
||||
kEmptyObject,
|
||||
kEnumerableProperty,
|
||||
} = require('internal/util');
|
||||
|
||||
@@ -379,7 +380,7 @@ function makeTextDecoderICU() {
|
||||
} = internalBinding('icu');
|
||||
|
||||
class TextDecoder {
|
||||
constructor(encoding = 'utf-8', options = {}) {
|
||||
constructor(encoding = 'utf-8', options = kEmptyObject) {
|
||||
encoding = `${encoding}`;
|
||||
validateObject(options, 'options', {
|
||||
nullable: true,
|
||||
@@ -408,7 +409,7 @@ function makeTextDecoderICU() {
|
||||
}
|
||||
|
||||
|
||||
decode(input = empty, options = {}) {
|
||||
decode(input = empty, options = kEmptyObject) {
|
||||
validateDecoder(this);
|
||||
if (isAnyArrayBuffer(input)) {
|
||||
input = lazyBuffer().from(input);
|
||||
@@ -453,7 +454,7 @@ function makeTextDecoderJS() {
|
||||
}
|
||||
|
||||
class TextDecoder {
|
||||
constructor(encoding = 'utf-8', options = {}) {
|
||||
constructor(encoding = 'utf-8', options = kEmptyObject) {
|
||||
encoding = `${encoding}`;
|
||||
validateObject(options, 'options', {
|
||||
nullable: true,
|
||||
@@ -481,7 +482,7 @@ function makeTextDecoderJS() {
|
||||
this[kBOMSeen] = false;
|
||||
}
|
||||
|
||||
decode(input = empty, options = {}) {
|
||||
decode(input = empty, options = kEmptyObject) {
|
||||
validateDecoder(this);
|
||||
if (isAnyArrayBuffer(input)) {
|
||||
input = lazyBuffer().from(input);
|
||||
|
||||
@@ -17,6 +17,7 @@ const {
|
||||
|
||||
const {
|
||||
customInspectSymbol: kInspect,
|
||||
kEmptyObject,
|
||||
} = require('internal/util');
|
||||
|
||||
const { inspect } = require('util');
|
||||
@@ -352,7 +353,7 @@ internalRecordableHistogram.prototype[kDeserialize] = () => {};
|
||||
* }} [options]
|
||||
* @returns {RecordableHistogram}
|
||||
*/
|
||||
function createHistogram(options = {}) {
|
||||
function createHistogram(options = kEmptyObject) {
|
||||
validateObject(options, 'options');
|
||||
const {
|
||||
lowest = 1,
|
||||
|
||||
@@ -11,6 +11,7 @@ const {
|
||||
const { setPromiseHooks } = internalBinding('async_wrap');
|
||||
const { triggerUncaughtException } = internalBinding('errors');
|
||||
|
||||
const { kEmptyObject } = require('internal/util');
|
||||
const { validatePlainFunction } = require('internal/validators');
|
||||
|
||||
const hooks = {
|
||||
@@ -101,7 +102,7 @@ const onBefore = makeUseHook('before');
|
||||
const onAfter = makeUseHook('after');
|
||||
const onSettled = makeUseHook('settled');
|
||||
|
||||
function createHook({ init, before, after, settled } = {}) {
|
||||
function createHook({ init, before, after, settled } = kEmptyObject) {
|
||||
const hooks = [];
|
||||
|
||||
if (init) ArrayPrototypePush(hooks, onInit(init));
|
||||
|
||||
Reference in New Issue
Block a user