From 7fca10ffab3943981e122b1d67bb52bad5c92a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8F=9C?= Date: Fri, 11 Feb 2022 21:02:12 +0800 Subject: [PATCH] fs: refactor to use ES2020 syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41903 Reviewed-By: Tobias Nießen Reviewed-By: Antoine du Hamel --- lib/fs.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 0e2bbbcc6362e3..7cc28b85e98e73 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -2516,7 +2516,7 @@ function realpathSync(p, options) { } resolvedLink = pathModule.resolve(previous, linkTarget); - if (cache) cache.set(base, resolvedLink); + cache?.set(base, resolvedLink); if (!isWindows) seenLinks[id] = linkTarget; } @@ -3041,8 +3041,7 @@ ObjectDefineProperties(fs, { configurable: true, enumerable: true, get() { - if (promises === null) - promises = require('internal/fs/promises').exports; + promises ??= require('internal/fs/promises').exports; return promises; } }