More explanation of all the projects in the README files.

Zed A. Shaw 2 years ago
parent 931f3a63ca
commit 8cd18c6f8c
  1. 14
  2. 10
  3. 25
  4. 23
  5. 6
  6. 2

@ -10,3 +10,17 @@ This is exercise 01 of `JavaScript Level 2` in [Learn JavaScript the Hard Way](h
* `step6.js` -- Second solution that uses [util.promisify]( to convert the `spectrum` callback to a `Promise` automatically.
If you attempt this challenge then point me at your solution at [@lzsthw]( and I'll take a look.
## Learning Objectives
You aren't really learning about CSVs, but actually learning about how to deal with old APIs that use callbacks when you need Promises. The `csv-spectrum` library uses an old style of operation that loads your data then calls a function for you to process the data. These days APIs need Promises, and use async/await to deal with the promises. Using what you learned from the previous module `JavaScript Level 1` you learned quite a lot about async/await/Promise/callbacks so now you apply that knowledge to deal with `csv-spectrum`.
## If You Get Stuck
Remember the programming process of:
1. Write comments in human language describing what the code should do.
2. Write pseudo-code (p-code) under those comments to bridge from human to code.
3. Slowly convert the p-code to JavaScript and _run your script repeatedly while you do._
If you're stuck chances are you're not following this process. If you need a clue about how to handle the `csv-spectrum` API then jump to the `step5.js` file to see one way, and `step6.js` to see another. Try to figure it out for yourself, and if you want a clue, remember that the `resolve` parameter to a Promise can be called inside a callback.

@ -2,10 +2,18 @@
In this exercise you'll take a webserver log I've created and parse the log file then filter the log for special events or information. You have a couple of approaches:
1. Brute force the filter by simply using a regex to scan the raw text.
2. Parse each line into meaningful data and filter on that.
The two samples in this directory get you started with both approaches. The `step1.js` file starts off the brute force `RegEx` method while the `step2.js` starts off the parsing method.
Keep in mind these are not solutions. They're starter file so you can get going without having to struggle with all of the setup. Once you're done you should attempt this again but do it entirely from nothing so you know how that's done.
## Learning Objectives
As with all of these exercises you're not really learning about the parsing log files. Your actual goal is:
1. Learn how a [RegExp]( works.
2. Learn how to do more than just simple regular expression matching lines. This would be a next level challenge.
A small side adventure is how to load and process text files, but you should have learned that from Ex 01.

@ -1,3 +1,26 @@
## Replicate `ls`
This starts you off with a simple command line parsing library and a globbing library to get going.
This starts you off with a simple command line parsing library and a globbing library to get going named [fast-glob]( "Globbing" is what you're doing when you use regular expression patterns to match files like this:
ls *.txt
The `fast-glob` library is a good library with only one quirk to watch out for: It will not convert `\` (backslash) characters to `/` in your glob. That means if you use `C:\Users\zed\*.txt` it will fail. You'll have to convert all `\` to `/` on Windows.
## File Attributes
Part of the `ls` command is printing out the attributes of a file. For that you'll need `fs.stat` found in the [fs]( module.
## Removing `fast-glob`
If you can get your `ls` copy working with `fast-glob` then try removing `fast-glob` and replicate its functionality with your own code. You'll need the [fs]( module and specifically the `readdir` function.
## Learning Objectives
As with all of the exercises thus far you aren't just learning how to replicated `ls` but you'll also:
1. Learn more about the `fs` module.
2. Learn how to process command line options. Try [commander](
3. Learn how to list files recursively based on a pattern using `fast-glob` and how `fast-glob` works by replacing it.
4. Learn about file attributes with the `fs.stat` function.

@ -1 +1,24 @@
## Replicate `find`
This exercise is very similar to the `ls` exercise, but instead of simply listing based on a pattern you are taking various commands to more finely control the search. This will help you solidify your understanding of the `fs` module which will be _essential_ for future exercises.
## Notes on Commander.js
The `find` command is an odd one because it uses the non-standard `-name` style (one dash, one word) while the rest of Unix tools use `--name` style (two dash, one word) or `-n` (one dash, one letter) style. For now, if you want to keep using [commander.js]( then you'll have to use the `--name` style and just go with it for now.
## `find` For Windows
Windows doesn't have `find` so you'll have to research how it works either inside `Windows Subsystem for Linux` or from the [man page](
Another option is to replicate the PowerShell [Get-ChildItem]( or `gci` for short. If you're not interested in running WSL for this exercise then I recommend this path, but my tutorial will replicate `find`.
## Learning Objectives
This exercise is all about cementing your understanding of everything learned so far:
1. Patterns using Regular Expressions (RegExp).
2. Recursively processing and finding files.
3. Using `fs.stat` to read the attributes of a file.
4. Getting command line options from the user.
Once you're done with this exercise you should be well versed in files, directories, file attributes, and how to find them for processing.

@ -3,9 +3,9 @@ import glob from "fast-glob";
import { program } from "commander";
.description("ls replica")
.description("find replica")

@ -4,4 +4,4 @@ This exercise has you use a templating system, and what you've learned from Ex 0
Since you've gone through the HTML and CSS portions of the course you should be able to create a decent starter CSS, but I highly suggest you just create a quick one using [blockstart.css]( or even grab a premade "classless CSS" to get started. You can also use the one from the course at []( which will get you started as well, and is also a classless CSS.
The key point of the last paragraph is to _not_ become obsesses with the CSS at first, but instead to get your .md file processing working right, then make your static blog look nice.
The key point of the last paragraph is to _not_ become obsessed with the CSS at first, but instead to get your .md file processing working right, then make your static blog look nice.