From cc133c443226867bb8195c19c4864b7d3e8ca6a0 Mon Sep 17 00:00:00 2001 From: jy95 Date: Sat, 22 Sep 2018 21:13:42 +0200 Subject: [PATCH] test: use ES2017 syntax in test-fs-open-* Update test-fs-open-flags to take advantage of destructuring and default values. Update test-fs-open-mode-mask to use a ternary to make use of a constant possible. PR-URL: https://github.com/nodejs/node/pull/23031 Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-fs-open-flags.js | 20 +++++++++++--------- test/parallel/test-fs-open-mode-mask.js | 8 +------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-fs-open-flags.js b/test/parallel/test-fs-open-flags.js index 546d68e31274f4..d1fee24de690ac 100644 --- a/test/parallel/test-fs-open-flags.js +++ b/test/parallel/test-fs-open-flags.js @@ -29,15 +29,17 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -const O_APPEND = fs.constants.O_APPEND || 0; -const O_CREAT = fs.constants.O_CREAT || 0; -const O_EXCL = fs.constants.O_EXCL || 0; -const O_RDONLY = fs.constants.O_RDONLY || 0; -const O_RDWR = fs.constants.O_RDWR || 0; -const O_SYNC = fs.constants.O_SYNC || 0; -const O_DSYNC = fs.constants.O_DSYNC || 0; -const O_TRUNC = fs.constants.O_TRUNC || 0; -const O_WRONLY = fs.constants.O_WRONLY || 0; +// 0 if not found in fs.constants +const { O_APPEND = 0, + O_CREAT = 0, + O_EXCL = 0, + O_RDONLY = 0, + O_RDWR = 0, + O_SYNC = 0, + O_DSYNC = 0, + O_TRUNC = 0, + O_WRONLY = 0 +} = fs.constants; const { stringToFlags } = require('internal/fs/utils'); diff --git a/test/parallel/test-fs-open-mode-mask.js b/test/parallel/test-fs-open-mode-mask.js index 0cd9a2c5923a71..4100fbb32c2046 100644 --- a/test/parallel/test-fs-open-mode-mask.js +++ b/test/parallel/test-fs-open-mode-mask.js @@ -7,13 +7,7 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs'); -let mode; - -if (common.isWindows) { - mode = 0o444; -} else { - mode = 0o644; -} +const mode = common.isWindows ? 0o444 : 0o644; const maskToIgnore = 0o10000;