Skip to content

Conversation

@Aseke09
Copy link

@Aseke09 Aseke09 commented Oct 26, 2025

  1. Link to the task: https://github.com/AlreadyBored/nodejs-assignments/blob/main/assignments/nodejs-basics/assignment.md

  2. Oct 27 06:00

  3. create.js - function creates new file fresh.txt with content I am fresh and young inside of the files folder (if file already exists Error with message FS operation failed throws)
    copy.js - function copies folder files with all its content into folder files_copy at the same level (if files folder doesn't exist or files_copy has already been created Error with message FS operation failed throws)
    rename.js - function that renames file wrongFilename.txt to properFilename with extension .md (if there's no file wrongFilename.txt or properFilename.md already exists Error with message FS operation throws)
    delete.js - function deletes file fileToRemove.txt (if there's no file fileToRemove.txt Error with message FS operation failed throws)
    list.js - function prints array of all filenames from files folder into console (if files folder doesn't exists Error with message FS operation failed throws)
    read.js - function prints content of the fileToRead.txt into console (if there's no file fileToRead.txt Error with message FS operation failed throws)

    Command line interface(src/cli)
    env.js - function parses environment variables with prefix RSS_ and prints them to the console in the format RSS_name1=value1; RSS_name2=value2
    args.js - function parses command line arguments (given in format --propName value --prop2Name value2, you don't need to validate it) and prints them to the console in the format propName is value, prop2Name is value2

    Modules(src/modules)
    cjsToEsm.cjs - rewriten to it's equivalent in ECMAScript notation (and renamed to esm.mjs)

    Hash (src/hash)
    calcHash.js - function calculates SHA256 hash for file fileToCalculateHashFor.txt and logs it into console as hex using Streams API
    Streams (src/streams)
    read.js - function reads file fileToRead.txt content using Readable Stream and prints it's content into process.stdout
    write.js - function writes process.stdin data into file fileToWrite.txt content using Writable Stream
    transform.js - function reads data from process.stdin, reverses text using Transform Stream and then writes it into process.stdout

    Zlib (src/zip)
    compress.js - function compresses file fileToCompress.txt to archive.gz using zlib and Streams API**(it creates archive.zg but do not deletes fileToCompress.txt)**
    decompress.js - function decompresses archive.gz back to the fileToCompress.txt with same content as before compression using zlib and Streams API**(to test it functionality delete old fileToCompress.txt!)**

    Worker Threads (src/wt)
    worker.js - function work with data received from main thread and function sends result of the computation to the main thread
    main.js - function creates number of worker threads (equal to the number of host machine logical CPU cores) from file worker.js and able to send data to those threads and to receive result of the computation from them.
    The results are array of objects with 2 properties:
    status - 'resolved' in case of successfully received value from worker or 'error' in case of error in worker
    data - value from worker in case of success or null in case of error in worker
    The results in the array must be in the same order that the workers were created
    [
    { status: 'resolved', data: 55 },
    { status: 'resolved', data: 89 },
    { status: 'resolved', data: 144 },
    { status: 'resolved', data: 233 }
    ]
    Child Processes (src/cp)
    cp.js - function spawnChildProcess that receives array of arguments args and creates child process from file script.js, passing these args to it. This function creates IPC-channel between stdin and stdout of master process and child process:
    child process stdin receives input from master process stdin
    child process stdout sends data to master process stdout
    output:
    Total number of arguments is 3
    Arguments: ["rs","2025","node.js"]

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.

1 participant