Giter Club home page Giter Club logo

syncuniquefinder's Introduction

Question!

Write a function that

  • takes in an array of filepaths as parameter
  • return a list of unique emails that don't belong to sync.com Note: The filepaths and paths to actual files, for example: /home/surya/emailfiles/file1.txt and /home/surya/emailfiles/file2.txt. And these files contain email addresses. One address per line.

Function explanation

test

The findUniqueEmails function uses a set to store final result of unique email addresses. Using a set ensures that duplicate email addresses are automatically eliminated.

The function uses asynchronous iteration to process file content line by line. Asynchronous iteration allows the function to handle large files without blocking, will result in improving performance.

By using asynchronous iteration and concurrency with Promise.allSettled, the function can process multiple files concurrently.

If there are any issues during this process, such as invalid email formats or file not found errors, it collect these errors for later handling.

How to run?

To run this code, you'll need the following:

Node.js

Download and install Node.js > v18.13.0 from the official website (https://nodejs.org/en).

Install dependencies

Use command below to install dependencies

npm install

Available Scripts

build

Runs the TypeScript compiler (tsc) to compile the TypeScript files into JavaScript files.

start:prod

Performs the following tasks:

  1. Removes the existing build directory.
  2. Builds the project by executing the build script.
  3. Starts the application in production mode by running the compiled index.js file with gc tracing enabled.

start:dev

Starts the application in development mode using nodemon, which automatically restarts the server when changes are detected in the source files.

test

Executes the tests written in TypeScript located in the test directory. It requires ts-node to compile TypeScript files on the fly before running the tests.

syncuniquefinder's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.