word-scanner 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Word Counter CLI
2
+
3
+ Count words in a text file.
4
+
5
+ ## Installation
6
+
7
+ npx word-counter-cli file.txt
8
+
9
+ ## Usage
10
+
11
+ word-counter file.txt
12
+
13
+ word-counter file.txt node
14
+
15
+ word-counter file.txt --top 10
package/app.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'node:fs/promises';
4
+
5
+ const filePath = process.argv[2];
6
+ const searchWord = process.argv[3];
7
+
8
+
9
+
10
+ const fileContent = await fs.readFile(filePath , "utf-8")
11
+
12
+ const wordsArray = fileContent.split(/[\W]/).filter((w)=> w)
13
+
14
+
15
+ const wordsCount = {};
16
+
17
+
18
+ wordsArray.forEach((word)=> {
19
+ if(!wordsCount[word]){
20
+ wordsCount[word] = 1;
21
+ }else{
22
+
23
+
24
+ wordsCount[word]++;
25
+ }
26
+ })
27
+
28
+ if(searchWord){
29
+ console.log(
30
+ `${searchWord} appears ${wordsCount[searchWord.toLocaleLowerCase()] || 0} times`
31
+ )
32
+ }else{
33
+ console.log(wordsCount)
34
+ }
35
+
36
+
package/file-1.txt ADDED
@@ -0,0 +1,11 @@
1
+ "
2
+
3
+ Node.js is a powerful JavaScript runtime built on Chrome's V8 engine. It allows developers to run JavaScript outside the browser and build fast, scalable network applications. One of the key features of Node.js is its event-driven, non-blocking I/O model, which makes it lightweight and efficient. This architecture is particularly useful for applications that handle a large number of simultaneous connections, such as chat applications, real-time collaboration tools, and APIs.
4
+
5
+ When learning backend development, understanding how Node.js works internally can be very beneficial. Developers often start with simple scripts and gradually move towards building RESTful APIs using frameworks like Express.js. Along the way, they learn about modules, file systems, streams, buffers, events, and asynchronous programming. These concepts form the foundation of modern backend development and are frequently used in production applications.
6
+
7
+ Another important aspect of backend development is working with databases. MongoDB is a popular NoSQL database that integrates well with Node.js applications. Using libraries like Mongoose, developers can define schemas, validate data, and interact with the database in a structured manner. Authentication and authorization are also critical topics, as they ensure that only authorized users can access protected resources.
8
+
9
+ As projects grow larger, developers need to focus on performance, security, and maintainability. Techniques such as caching with Redis, storing files in cloud services like AWS S3, and implementing proper logging can significantly improve application quality. Understanding deployment strategies, CI/CD pipelines, and monitoring tools is also important for running applications in production environments.
10
+
11
+ Building projects is one of the best ways to learn programming. A simple project like a word counter can teach file handling, command-line arguments, string manipulation, and error handling. More advanced projects can introduce concepts such as streams, worker threads, databases, authentication systems, and cloud deployments. Consistent practice and hands-on experience are the keys to becoming a skilled software developer."
package/file-2.txt ADDED
@@ -0,0 +1,13 @@
1
+ Artificial Intelligence (AI) is transforming the way people interact with technology. From virtual assistants and recommendation systems to self-driving cars and advanced medical diagnostics, AI is becoming an essential part of modern life. Organizations across different industries are investing heavily in AI research and development to improve efficiency, reduce costs, and create innovative products and services.
2
+
3
+ Machine Learning is a subset of Artificial Intelligence that enables computers to learn from data without being explicitly programmed. Instead of following fixed instructions, machine learning models identify patterns in large datasets and make predictions based on those patterns. Popular applications include fraud detection, image recognition, natural language processing, and personalized content recommendations.
4
+
5
+ Data plays a crucial role in the success of machine learning systems. High-quality datasets help models learn meaningful patterns and improve their accuracy. Data scientists spend a significant amount of time collecting, cleaning, and analyzing data before training machine learning models. Poor-quality data can lead to inaccurate predictions and unreliable outcomes.
6
+
7
+ Deep Learning is a specialized branch of machine learning that uses neural networks with multiple layers. These networks are inspired by the structure of the human brain and are capable of learning highly complex patterns. Deep learning has achieved remarkable success in fields such as computer vision, speech recognition, and language translation. Modern AI systems such as chatbots and image generators often rely on deep learning techniques.
8
+
9
+ Software developers are increasingly expected to understand the basics of Artificial Intelligence and Machine Learning. While not every developer needs to become a data scientist, having a strong understanding of AI concepts can be extremely valuable. Developers can integrate AI services into web applications, mobile apps, and enterprise systems to provide intelligent features and improve user experiences.
10
+
11
+ Building AI-powered applications requires a combination of programming, mathematics, and problem-solving skills. Languages such as Python and JavaScript are commonly used for developing AI solutions. Frameworks and libraries like TensorFlow, PyTorch, and Scikit-learn simplify the process of building and training machine learning models. Cloud platforms also provide managed AI services that allow developers to experiment with advanced technologies without managing complex infrastructure.
12
+
13
+ As Artificial Intelligence continues to evolve, ethical considerations are becoming increasingly important. Issues such as data privacy, algorithmic bias, transparency, and accountability must be carefully addressed. Organizations need to ensure that AI systems are designed and deployed responsibly. The future of AI is promising, but it also requires thoughtful planning and responsible innovation to maximize benefits while minimizing risks.
package/package.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "word-scanner",
3
+ "version": "1.0.1",
4
+ "type" : "module",
5
+ "bin": {
6
+ "word-counter": "./app.js"
7
+ }
8
+ }