Skip to content

feat: add Node.js fundamentals task#1

Open
zhannach wants to merge 6 commits intomasterfrom
01-nodejs-fundamentals
Open

feat: add Node.js fundamentals task#1
zhannach wants to merge 6 commits intomasterfrom
01-nodejs-fundamentals

Conversation

@zhannach
Copy link
Copy Markdown
Owner

@zhannach zhannach commented Mar 7, 2026

@zhannach zhannach changed the title feat: add CLI and modules tasks feat: add Node.js fundamentals task Mar 8, 2026
Copy link
Copy Markdown

@BorysovskaOA BorysovskaOA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.
Just 1 assignment requirement not met for streams in hashing.
All other are just improvements.

Comment thread src/cli/interactive.js
break;

case "exit":
console.log("Goodbye!");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write here rl.close() to reuse logic of closing the application.

Comment thread src/hash/verify.js

try {
const fileBuffer = await fs.promises.readFile(absolutePath);
const actualHash = createHash("sha256").update(fileBuffer).digest("hex");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In assignment it's required to calculate hash using Streams API.

Comment thread src/cp/execCommand.js
@@ -1,10 +1,17 @@
import {spawn} from "child_process";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better import built-in modules with 'node:' prefix.
https://nodejs.org/dist/latest-v22.x/docs/api/esm.html#node-imports

Comment thread src/wt/main.js
}
const sortedChunks = new Array(chunks.length);

const workers = chunks.map((chunk, index) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/zip/compressDir.js
import path from "path";
import {createBrotliCompress} from "zlib";

const {promises: fsp} = fs;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead you can import with node:fs/promises

Comment thread src/zip/compressDir.js
const {promises: fsp} = fs;

async function getFiles(dir, base = dir, result = []) {
const files = await fsp.readdir(dir, {withFileTypes: true});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can read all files by one call with readdir(dir, {withFileTypes: true, recursive: true })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants