Skip to content

Commit cc133c4

Browse files
jy95BridgeAR
authored andcommitted
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: #23031 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a7a1cb4 commit cc133c4

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

test/parallel/test-fs-open-flags.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ const assert = require('assert');
2929
const fs = require('fs');
3030
const path = require('path');
3131

32-
const O_APPEND = fs.constants.O_APPEND || 0;
33-
const O_CREAT = fs.constants.O_CREAT || 0;
34-
const O_EXCL = fs.constants.O_EXCL || 0;
35-
const O_RDONLY = fs.constants.O_RDONLY || 0;
36-
const O_RDWR = fs.constants.O_RDWR || 0;
37-
const O_SYNC = fs.constants.O_SYNC || 0;
38-
const O_DSYNC = fs.constants.O_DSYNC || 0;
39-
const O_TRUNC = fs.constants.O_TRUNC || 0;
40-
const O_WRONLY = fs.constants.O_WRONLY || 0;
32+
// 0 if not found in fs.constants
33+
const { O_APPEND = 0,
34+
O_CREAT = 0,
35+
O_EXCL = 0,
36+
O_RDONLY = 0,
37+
O_RDWR = 0,
38+
O_SYNC = 0,
39+
O_DSYNC = 0,
40+
O_TRUNC = 0,
41+
O_WRONLY = 0
42+
} = fs.constants;
4143

4244
const { stringToFlags } = require('internal/fs/utils');
4345

test/parallel/test-fs-open-mode-mask.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ const assert = require('assert');
77
const path = require('path');
88
const fs = require('fs');
99

10-
let mode;
11-
12-
if (common.isWindows) {
13-
mode = 0o444;
14-
} else {
15-
mode = 0o644;
16-
}
10+
const mode = common.isWindows ? 0o444 : 0o644;
1711

1812
const maskToIgnore = 0o10000;
1913

0 commit comments

Comments
 (0)