From 57f71da64d090b3ada23cceb62c70894107a80f2 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 65c828ea110d2d..9c0173ec27c1c0 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; } }