Conversation
zhannach
commented
Mar 7, 2026
- Task description: https://github.com/AlreadyBored/nodejs-assignments/blob/main/assignments-v2/01-nodejs-fundamentals/assignment.md
- Deadline: 09.02.2026
- Score: 200
BorysovskaOA
left a comment
There was a problem hiding this comment.
Good work.
Just 1 assignment requirement not met for streams in hashing.
All other are just improvements.
| break; | ||
|
|
||
| case "exit": | ||
| console.log("Goodbye!"); |
There was a problem hiding this comment.
You can write here rl.close() to reuse logic of closing the application.
|
|
||
| try { | ||
| const fileBuffer = await fs.promises.readFile(absolutePath); | ||
| const actualHash = createHash("sha256").update(fileBuffer).digest("hex"); |
There was a problem hiding this comment.
In assignment it's required to calculate hash using Streams API.
| @@ -1,10 +1,17 @@ | |||
| import {spawn} from "child_process"; | |||
There was a problem hiding this comment.
It's better import built-in modules with 'node:' prefix.
https://nodejs.org/dist/latest-v22.x/docs/api/esm.html#node-imports
| } | ||
| const sortedChunks = new Array(chunks.length); | ||
|
|
||
| const workers = chunks.map((chunk, index) => { |
There was a problem hiding this comment.
It's not obvious why we should update sortedChunks from worker function.
It's better to return the result inside worker function with resolve(sorted); so it will resolve with correct index automatically.
| import path from "path"; | ||
| import {createBrotliCompress} from "zlib"; | ||
|
|
||
| const {promises: fsp} = fs; |
There was a problem hiding this comment.
Instead you can import with node:fs/promises
| const {promises: fsp} = fs; | ||
|
|
||
| async function getFiles(dir, base = dir, result = []) { | ||
| const files = await fsp.readdir(dir, {withFileTypes: true}); |
There was a problem hiding this comment.
You can read all files by one call with readdir(dir, {withFileTypes: true, recursive: true })