| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,7 +100,7 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) { | |||
| 100 | 100 | // We have to test new.target here to see if this function is called | |
| 101 | 101 | // with new, because we need to define a custom instanceof to accommodate | |
| 102 | 102 | // the global console. | |
| 103 | - if (!new.target) { | ||
| 103 | + if (new.target === undefined) { | ||
| 104 | 104 | return ReflectConstruct(Console, arguments); | |
| 105 | 105 | } | |
| 106 | 106 | ||
@@ -486,7 +486,7 @@ const consoleMethods = { | |||
| 486 | 486 | if (tabularData === null || typeof tabularData !== 'object') | |
| 487 | 487 | return this.log(tabularData); | |
| 488 | 488 | ||
| 489 | - if (cliTable === undefined) cliTable = require('internal/cli_table'); | ||
| 489 | + cliTable ??= require('internal/cli_table'); | ||
| 490 | 490 | const final = (k, v) => this.log(cliTable(k, v)); | |
| 491 | 491 | ||
| 492 | 492 | const _inspect = (v) => { | |
@@ -570,8 +570,7 @@ const consoleMethods = { | |||
| 570 | 570 | } else { | |
| 571 | 571 | const keys = properties || ObjectKeys(item); | |
| 572 | 572 | for (const key of keys) { | |
| 573 | - if (map[key] === undefined) | ||
| 574 | - map[key] = []; | ||
| 573 | + map[key] ??= []; | ||
| 575 | 574 | if ((primitive && properties) || | |
| 576 | 575 | !ObjectPrototypeHasOwnProperty(item, key)) | |
| 577 | 576 | map[key][i] = ''; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -175,24 +175,19 @@ let assert; | |||
| 175 | 175 | ||
| 176 | 176 | let internalUtil = null; | |
| 177 | 177 | function lazyInternalUtil() { | |
| 178 | - if (!internalUtil) { | ||
| 179 | - internalUtil = require('internal/util'); | ||
| 180 | - } | ||
| 178 | + internalUtil ??= require('internal/util'); | ||
| 181 | 179 | return internalUtil; | |
| 182 | 180 | } | |
| 183 | 181 | ||
| 184 | 182 | let internalUtilInspect = null; | |
| 185 | 183 | function lazyInternalUtilInspect() { | |
| 186 | - if (!internalUtilInspect) { | ||
| 187 | - internalUtilInspect = require('internal/util/inspect'); | ||
| 188 | - } | ||
| 184 | + internalUtilInspect ??= require('internal/util/inspect'); | ||
| 189 | 185 | return internalUtilInspect; | |
| 190 | 186 | } | |
| 191 | 187 | ||
| 192 | 188 | let buffer; | |
| 193 | 189 | function lazyBuffer() { | |
| 194 | - if (buffer === undefined) | ||
| 195 | - buffer = require('buffer').Buffer; | ||
| 190 | + buffer ??= require('buffer').Buffer; | ||
| 196 | 191 | return buffer; | |
| 197 | 192 | } | |
| 198 | 193 | ||
@@ -421,7 +416,7 @@ function E(sym, val, def, ...otherClasses) { | |||
| 421 | 416 | function getMessage(key, args, self) { | |
| 422 | 417 | const msg = messages.get(key); | |
| 423 | 418 | ||
| 424 | - if (assert === undefined) assert = require('internal/assert'); | ||
| 419 | + assert ??= require('internal/assert'); | ||
| 425 | 420 | ||
| 426 | 421 | if (typeof msg === 'function') { | |
| 427 | 422 | assert( | |
@@ -449,19 +444,15 @@ function getMessage(key, args, self) { | |||
| 449 | 444 | let uvBinding; | |
| 450 | 445 | ||
| 451 | 446 | function lazyUv() { | |
| 452 | - if (!uvBinding) { | ||
| 453 | - uvBinding = internalBinding('uv'); | ||
| 454 | - } | ||
| 447 | + uvBinding ??= internalBinding('uv'); | ||
| 455 | 448 | return uvBinding; | |
| 456 | 449 | } | |
| 457 | 450 | ||
| 458 | 451 | const uvUnmappedError = ['UNKNOWN', 'unknown error']; | |
| 459 | 452 | ||
| 460 | 453 | function uvErrmapGet(name) { | |
| 461 | 454 | uvBinding = lazyUv(); | |
| 462 | - if (!uvBinding.errmap) { | ||
| 463 | - uvBinding.errmap = uvBinding.getErrorMap(); | ||
| 464 | - } | ||
| 455 | + uvBinding.errmap ??= uvBinding.getErrorMap(); | ||
| 465 | 456 | return MapPrototypeGet(uvBinding.errmap, name); | |
| 466 | 457 | } | |
| 467 | 458 | ||
@@ -588,7 +579,7 @@ const errnoException = hideStackFrames( | |||
| 588 | 579 | // getSystemErrorName(err) to guard against invalid arguments from users. | |
| 589 | 580 | // This can be replaced with [ code ] = errmap.get(err) when this method | |
| 590 | 581 | // is no longer exposed to user land. | |
| 591 | - if (util === undefined) util = require('util'); | ||
| 582 | + util ??= require('util'); | ||
| 592 | 583 | const code = util.getSystemErrorName(err); | |
| 593 | 584 | const message = original ? | |
| 594 | 585 | `${syscall} ${code} ${original}` : `${syscall} ${code}`; | |
@@ -622,7 +613,7 @@ const exceptionWithHostPort = hideStackFrames( | |||
| 622 | 613 | // getSystemErrorName(err) to guard against invalid arguments from users. | |
| 623 | 614 | // This can be replaced with [ code ] = errmap.get(err) when this method | |
| 624 | 615 | // is no longer exposed to user land. | |
| 625 | - if (util === undefined) util = require('util'); | ||
| 616 | + util ??= require('util'); | ||
| 626 | 617 | const code = util.getSystemErrorName(err); | |
| 627 | 618 | let details = ''; | |
| 628 | 619 | if (port && port > 0) { | |
@@ -1238,7 +1229,7 @@ E('ERR_INVALID_ARG_TYPE', | |||
| 1238 | 1229 | } else if (typeof actual === 'function' && actual.name) { | |
| 1239 | 1230 | msg += `. Received function ${actual.name}`; | |
| 1240 | 1231 | } else if (typeof actual === 'object') { | |
| 1241 | - if (actual.constructor && actual.constructor.name) { | ||
| 1232 | + if (actual.constructor?.name) { | ||
| 1242 | 1233 | msg += `. Received an instance of ${actual.constructor.name}`; | |
| 1243 | 1234 | } else { | |
| 1244 | 1235 | const inspected = lazyInternalUtilInspect() | |
@@ -1332,7 +1323,7 @@ E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => { | |||
| 1332 | 1323 | }, TypeError); | |
| 1333 | 1324 | E('ERR_INVALID_RETURN_VALUE', (input, name, value) => { | |
| 1334 | 1325 | let type; | |
| 1335 | - if (value && value.constructor && value.constructor.name) { | ||
| 1326 | + if (value?.constructor?.name) { | ||
| 1336 | 1327 | type = `instance of ${value.constructor.name}`; | |
| 1337 | 1328 | } else { | |
| 1338 | 1329 | type = `type ${typeof value}`; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments