* Guards an access/call on `object` with optional chaining when supported, * otherwise an equivalent `&&` short-circuit. `object` is evaluated twice in * the fallback, so it must be side-effect free. * @param {string} object base expression (side-effect free) * @param {string} access continu
(object, access)
| 384 | * @returns {string} guarded access expression |
| 385 | */ |
| 386 | optionalChaining(object, access) { |
| 387 | if (this.supportsOptionalChaining()) { |
| 388 | return `${object}?.${access}`; |
| 389 | } |
| 390 | const sep = access[0] === "(" || access[0] === "[" ? "" : "."; |
| 391 | return `${object} && ${object}${sep}${access}`; |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * Reads a node builtin via `process.getBuiltinModule()`, guarded to stay falsy off node so universal `["node", "web"]` bundles don't crash (also falsy on node <22.3). |
no test coverage detected