WebFund 2016W: Assignment 1
This assignment is not yet finalized.
This assignment is due on January 20th on cuLearn.
In this assignment you will writing two programs, words-sync.js and words-async.js. These programs will make use of synchronous and asynchronous I/O is the manner of the programs from Tutorial 1.
These programs should both behave as follows:
- They should take two arguments, an input text file and an output file to create. Thus you run them by typing "node words-sync.js document.txt wordlist.txt", with document.txt being the file to be read and wordlist.txt is the file to be created.
- The output file should contain a list of words in the input file, one word per line, with each line terminated by a newline character ('\n'). These words should be sorted in ascending order, as ordered by the standard JavaScript Array.sort() method (with no comparison function specified).
- Once the output file has been created, the program should output "Finished!" to the console.
- For the purposes of this program, words can be defined as anything matching the \w operator. In other words, to split the document into words you may call split() using "/\W//" as the split regular expression.
- You may assume that the input file exists and is readable and the output file is writable. In other words you do not need to do any error checking (although it is appreciated).
In creating this program, don't forget that you can use standard JavaScript methods such as push(), pop(), shift(), and unshift(). And of course you'll need the methods from the Node fs module.
There are 10 points, allocated as follows:
- 4 points for producing the correct output given well-formed input.
- 4 points for correctly structuring the code into synchronous and asynchronous versions.
- 2 points for style (well-organized code, using reasonable algorithms and methods for solving the problem, etc).
Please submit your answers as a zip file called "<username>-comp2406-assign1.zip", where username is your MyCarletonOne username. This zip file should uncompress to a directory called "<username>-comp2406-assign1" and inside this directory should be three files: "words-sync.js", "words-async.js", and a text file "comments.txt".
"comments.txt" should:
- list any references you used to complete the assignment (documentation web sites, for example),
- list your collaborators, and
- optionally, should discuss any issues or concerns you had when completing this assignment.
Remember that while you are allowed to collaborate with others, plagiarism is not allowed. In other words you should not be copying any code or data directly from anywhere, and any assistance or inspiration should be credited. Any significant code similarity (beyond the code already given to you) will be considered plagiarism and will be reported to the Dean.