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
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

@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.

break;

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

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.


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

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.

@@ -1,10 +1,17 @@
import {spawn} from "child_process";

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

}
const sortedChunks = new Array(chunks.length);

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

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.

import path from "path";
import {createBrotliCompress} from "zlib";

const {promises: fsp} = fs;

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

const {promises: fsp} = fs;

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

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