-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtask15.js
More file actions
27 lines (19 loc) · 1010 Bytes
/
task15.js
File metadata and controls
27 lines (19 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { readFile, writeFile } from 'fs/promises'
/*
- Create a function, that opens the quote.txt and read its content and log it to the console.
- Reverse the content of the file character by character and write it to the reversed.txt.
- You can choose between the then and the async-await syntax.
- If the there is an error during the read or the write, log a fridenly error message to the console.
(you can test it, if you try to open a non existent file)
- use node.js's readFile() function's promise version.
syntax: readFile(path: string, encoding: string): Promise<string>
example: readFile('./some-file.txt', 'utf8')
- use node.js's writeFile() function's promise version.
syntax: writeFile(path: string, data: string, encoding: string): Promise
example: readFile('./some-file.txt', 'here is the file content','utf8')
Goal: Apply the promise theory to practice chained promises with a native library
with error handling.
*/
const task = () => {
}
task()