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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
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‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ const assert = require('assert');
2929
constfs=require('fs');
3030
constpath=require('path');
3131

32-
constO_APPEND=fs.constants.O_APPEND||0;
33-
constO_CREAT=fs.constants.O_CREAT||0;
34-
constO_EXCL=fs.constants.O_EXCL||0;
35-
constO_RDONLY=fs.constants.O_RDONLY||0;
36-
constO_RDWR=fs.constants.O_RDWR||0;
37-
constO_SYNC=fs.constants.O_SYNC||0;
38-
constO_DSYNC=fs.constants.O_DSYNC||0;
39-
constO_TRUNC=fs.constants.O_TRUNC||0;
40-
constO_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‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ const assert = require('assert');
77
constpath=require('path');
88
constfs=require('fs');
99

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

1812
constmaskToIgnore=0o10000;
1913

0 commit comments

Comments
(0)