File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
- const fs = require ( 'fs' ) . promises
1
+ const fs = require ( 'fs' )
2
+ const util = require ( 'util' )
2
3
const os = require ( 'os' )
3
4
os . EOL // instead of '\n'
4
5
6
+ const readFile = util . promisify ( fs . readFile )
7
+ const writeFile = util . promisify ( fs . writeFile )
8
+
5
9
Promise . all ( [
6
- fs . readFile ( __dirname + '/1.txt' ) ,
7
- fs . readFile ( __dirname + '/2.txt' ) ,
8
- fs . readFile ( __dirname + '/3.txt' )
10
+ readFile ( __dirname + '/1.txt' ) ,
11
+ readFile ( __dirname + '/2.txt' ) ,
12
+ readFile ( __dirname + '/3.txt' )
9
13
] ) . then ( ( arr ) => {
10
14
let nums = [ ]
11
15
arr . forEach ( ( fileData ) => {
12
16
nums = nums . concat ( fileData . toString ( ) . split ( os . EOL ) )
13
17
} )
14
18
nums = nums . sort ( ( a , b ) => a - b )
15
- return fs . writeFile ( __dirname + '/out2.txt' , nums )
19
+ return writeFile ( __dirname + '/out2.txt' , nums )
16
20
} ) . then ( ( ) => {
17
21
console . log ( 'All done!' )
18
- } )
22
+ } ) . catch ( )
You can’t perform that action at this time.
0 commit comments