The yarn lab incorporates a few steps:
- Install
yarn
- Create a new project with
yarn
- Installing/reinstall/syncing project dependencies
- Add/remove/update some dependencies
Questions? If you have any questions, ping #webguild.
This exercise is to build an API for recursively listing the files in a directory in parallel, or in other words, a recursive ls
. The purpose of this exercise is to practice control-flow for asynchronous IO, specifically running operations in serial and parallel. Additionally, this exercise will explore the fs
filesystem module from core.
IMPORTANT: Review the Control-flow Guide to familiarize yourself with async/await
. Ignore Promise
and callbacks for now.
The checkpoints below should be implemented as pairs. In pair programming, there are two roles: supervisor and driver.
(aka "errback" or "error first callback")
This week, we'll ensure our environments are properly setup and walk through the fundamentals of the node.js runtime with a focus on asynchronous programming, control-flow and IO. We'll keep things simple by sticking primarily to the filesystem, stdin and stdout to write basic CLIs like an asynchronous recursive readdir CLI.
Assignment 1: Filesystem CLIs due at 10:00pm
This week, we'll build a collection of common filesystem CLIs. The purpose of this project is to develop a basic understanding of control-flow and the node.js runtime, module system and ascyhronous APIs.
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Async Await</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | |
<style type="text/css"> | |
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); | |
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic); | |
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic); |
{ | |
"env": { | |
"node": true, | |
"es6": true | |
}, | |
"parser": "babel-eslint", | |
"rules": { | |
"no-throw-literal": 1, | |
"strict": "never", | |
"semi": [2, "never"], |
// in new iframe | |
var whitelist = { | |
// add whitelisted globals | |
}; | |
var handler = { | |
// Fundamental traps | |
getOwnPropertyDescriptor: function(name) { | |
var desc = Object.getOwnPropertyDescriptor(whitelist, name); |
The pre-work incorporates a few steps:
/* | |
pins: [{ | |
id, height | |
}] | |
*/ | |
// orderedByHeight = [{height: 0, index: 0}] | |
// Output: datastructure to describe pins | |
function layoutPins(pins, cols) { | |
// [{height: 0, index: 0}] |