Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pedrocarr/jsccwc-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wc-tool in javascript

Javascript solution to Coding Challenges first challenge: build your own wc tool

Make the command executable

chmod +x ./cmd/ccwc/cli.js

The command is now executable and can be executed globally by

npm link

Note that the alias for the command is on package.json and you can only use

ccwc [options] [filename]

Unit Tests

npm test

Testing

Step 1 - Count Bytes

js-ccwc-tool % wc -c test.txt
  342190 test.txt
js-ccwc-tool % ccwc -c test.txt
342190  test.txt

Step 2 - Count Lines

js-ccwc-tool % wc -l test.txt
    7146 test.txt
js-ccwc-tool % ccwc -l test.txt
7146    test.txt

Step 3 - Count Words

js-ccwc-tool % wc -w test.txt
   58164 test.txt
js-ccwc-tool % ccwc -w test.txt
58164   test.txt

Step 4 - Count Characters

js-ccwc-tool % wc -m test.txt
  339292 test.txt
js-ccwc-tool % ccwc -m test.txt
339292  test.txt

Step 5 - Default Options - Return Lines, Words and Bytes and the filename

js-ccwc-tool % wc test.txt
    7146   58164  342190 test.txt
js-ccwc-tool % ccwc test.txt
7146    58164   342190  test.txt

Step 6 (Final Step)

js-ccwc-tool % cat test.txt | wc -l
    7146
js-ccwc-tool % cat test.txt | ccwc -l
7146

About

a simple wc tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published