| 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 | ||
@@ -411,7 +406,7 @@ function E(sym, val, def, ...otherClasses) { | |||
| 411 | 406 | function getMessage(key, args, self) { | |
| 412 | 407 | const msg = messages.get(key); | |
| 413 | 408 | ||
| 414 | - if (assert === undefined) assert = require('internal/assert'); | ||
| 409 | + assert ??= require('internal/assert'); | ||
| 415 | 410 | ||
| 416 | 411 | if (typeof msg === 'function') { | |
| 417 | 412 | assert( | |
@@ -439,19 +434,15 @@ function getMessage(key, args, self) { | |||
| 439 | 434 | let uvBinding; | |
| 440 | 435 | ||
| 441 | 436 | function lazyUv() { | |
| 442 | - if (!uvBinding) { | ||
| 443 | - uvBinding = internalBinding('uv'); | ||
| 444 | - } | ||
| 437 | + uvBinding ??= internalBinding('uv'); | ||
| 445 | 438 | return uvBinding; | |
| 446 | 439 | } | |
| 447 | 440 | ||
| 448 | 441 | const uvUnmappedError = ['UNKNOWN', 'unknown error']; | |
| 449 | 442 | ||
| 450 | 443 | function uvErrmapGet(name) { | |
| 451 | 444 | uvBinding = lazyUv(); | |
| 452 | - if (!uvBinding.errmap) { | ||
| 453 | - uvBinding.errmap = uvBinding.getErrorMap(); | ||
| 454 | - } | ||
| 445 | + uvBinding.errmap ??= uvBinding.getErrorMap(); | ||
| 455 | 446 | return MapPrototypeGet(uvBinding.errmap, name); | |
| 456 | 447 | } | |
| 457 | 448 | ||
@@ -578,7 +569,7 @@ const errnoException = hideStackFrames( | |||
| 578 | 569 | // getSystemErrorName(err) to guard against invalid arguments from users. | |
| 579 | 570 | // This can be replaced with [ code ] = errmap.get(err) when this method | |
| 580 | 571 | // is no longer exposed to user land. | |
| 581 | - if (util === undefined) util = require('util'); | ||
| 572 | + util ??= require('util'); | ||
| 582 | 573 | const code = util.getSystemErrorName(err); | |
| 583 | 574 | const message = original ? | |
| 584 | 575 | `${syscall} ${code} ${original}` : `${syscall} ${code}`; | |
@@ -612,7 +603,7 @@ const exceptionWithHostPort = hideStackFrames( | |||
| 612 | 603 | // getSystemErrorName(err) to guard against invalid arguments from users. | |
| 613 | 604 | // This can be replaced with [ code ] = errmap.get(err) when this method | |
| 614 | 605 | // is no longer exposed to user land. | |
| 615 | - if (util === undefined) util = require('util'); | ||
| 606 | + util ??= require('util'); | ||
| 616 | 607 | const code = util.getSystemErrorName(err); | |
| 617 | 608 | let details = ''; | |
| 618 | 609 | if (port && port > 0) { | |
@@ -1224,7 +1215,7 @@ E('ERR_INVALID_ARG_TYPE', | |||
| 1224 | 1215 | } else if (typeof actual === 'function' && actual.name) { | |
| 1225 | 1216 | msg += `. Received function ${actual.name}`; | |
| 1226 | 1217 | } else if (typeof actual === 'object') { | |
| 1227 | - if (actual.constructor && actual.constructor.name) { | ||
| 1218 | + if (actual.constructor?.name) { | ||
| 1228 | 1219 | msg += `. Received an instance of ${actual.constructor.name}`; | |
| 1229 | 1220 | } else { | |
| 1230 | 1221 | const inspected = lazyInternalUtilInspect() | |
@@ -1320,7 +1311,7 @@ E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => { | |||
| 1320 | 1311 | }, TypeError); | |
| 1321 | 1312 | E('ERR_INVALID_RETURN_VALUE', (input, name, value) => { | |
| 1322 | 1313 | let type; | |
| 1323 | - if (value && value.constructor && value.constructor.name) { | ||
| 1314 | + if (value?.constructor?.name) { | ||
| 1324 | 1315 | type = `instance of ${value.constructor.name}`; | |
| 1325 | 1316 | } else { | |
| 1326 | 1317 | type = `type ${typeof value}`; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments