Skip to content

Commit d8d487c

Browse files
committed
Merge branch 'master' into child-process
2 parents 916cb5a + 9a17da5 commit d8d487c

21 files changed

Lines changed: 1771 additions & 3425 deletions

File tree

.eleventy.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
const moment = require("moment");
2+
3+
moment.locale("en");
4+
15
module.exports = function(eleventyConfig) {
6+
eleventyConfig.addFilter("dateIso", date => {
7+
return moment(date).toISOString();
8+
});
9+
10+
eleventyConfig.addFilter("dateReadable", date => {
11+
return moment(date).format("LL"); // E.g. May 31, 2019
12+
});
13+
214
eleventyConfig.addPassthroughCopy("css");
15+
eleventyConfig.addPassthroughCopy("js");
316
eleventyConfig.addPassthroughCopy("CNAME");
417
eleventyConfig.addLayoutAlias("default", "default.njk");
18+
eleventyConfig.addLayoutAlias("post", "post.njk");
519
return {
620
passthroughFileCopy: true
721
};

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true
6+
}

TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: default.njk
2+
layout: default
33
title: Your post title
44
---
55

_data/authors.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"john": {
3+
"name": "John Behan",
4+
"link": "/about/#john"
5+
},
6+
"ian": {
7+
"name": "Ian Read",
8+
"link": "/about/#ian"
9+
},
10+
"donovan": {
11+
"name": "Donovan Hutchinson",
12+
"link": "/about/#donovan"
13+
}
14+
}

_data/topics.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[
2+
{
3+
"title": "Buffers and Streams",
4+
"url": "/buffers-and-streams/"
5+
},
6+
{
7+
"title": "Control flow",
8+
"url": "/control-flow/"
9+
},
10+
{
11+
"title": "Child Processes",
12+
"url": "/child-processes/"
13+
},
14+
{
15+
"title": "Diagnostics",
16+
"url": "/diagnostics/"
17+
},
18+
{
19+
"title": "Error Handling",
20+
"url": "/error-handling/"
21+
},
22+
{
23+
"title": "Node.js CLI",
24+
"url": "/nodejs-cli/"
25+
},
26+
{
27+
"title": "Events",
28+
"url": "/events/"
29+
},
30+
{
31+
"title": "File System",
32+
"url": "/file-system/"
33+
},
34+
{
35+
"title": "JavaScript Prerequisites",
36+
"url": "/javascript-prerequisites/"
37+
},
38+
{
39+
"title": "Module system",
40+
"url": "/module-system/"
41+
},
42+
{
43+
"title": "Process/Operating System",
44+
"url": "/process-operating-system/"
45+
},
46+
{
47+
"title": "Package.json",
48+
"url": "/package-json/"
49+
},
50+
{
51+
"title": "Unit Testing",
52+
"url": "/unit-testing/"
53+
}
54+
]

_includes/base.njk

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: OpenJS NodeJS Application Developer Study Guide
3+
---
4+
<!doctype html>
5+
<html lang="en">
6+
<head>
7+
<meta charset="utf-8">
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9+
<title>{{ title }}</title>
10+
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
11+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.css">
12+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.css">
13+
<link rel="stylesheet" href="{{ "/css/main.css" | url }}">
14+
<link rel="stylesheet"
15+
href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.16.2/build/styles/default.min.css">
16+
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.16.2/build/highlight.min.js"></script>
17+
<script>
18+
hljs.initHighlightingOnLoad();
19+
</script>
20+
<script src="{{ "/js/main.js" | url }}"></script>
21+
</head>
22+
<body>
23+
<header class="container">
24+
<div class="row">
25+
<div class="column column-50">
26+
<h1 class="logo">
27+
<a href="/">ONAD Study Guide</a>
28+
</h1>
29+
</div>
30+
<div class="top-links column column-50">
31+
<ul>
32+
<li>
33+
<a href="https://training.linuxfoundation.org/certification/jsnad/" target="_blank" title="OpenJS Node.js Application Developer (JSNAD)">JSNAD Certification</a>
34+
</li>
35+
</ul>
36+
</div>
37+
</div>
38+
</header>
39+
<main class="container">
40+
<div class="row">
41+
<div class="sidebar column">
42+
<nav>
43+
<ul class="topics">
44+
{% for topic in topics %}
45+
<li data-topic="{{topic.url}}">
46+
<a href="{{ topic.url | url }}" {% if page.url === topic.url %} class="current" {% endif %}>{{topic.title}}</a>
47+
</li>
48+
{% endfor %}
49+
</ul>
50+
</nav>
51+
</div>
52+
<div class="main-content column column-75">
53+
{{ content | safe }}
54+
</div>
55+
</div>
56+
</main>
57+
<footer class="container">
58+
<div class="row">
59+
<div class="column column-75 column-offset-25">
60+
<p>
61+
<a href="https://github.com/Node-Study-Guide/openjs-nodejs-application-developer-study-guide/tree/master/{{ page.inputPath }}">Edit this page on GitHub</a>
62+
</p>
63+
</div>
64+
</div>
65+
66+
</footer>
67+
</body>
68+
</html>

_includes/default.njk

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,7 @@
11
---
2-
title: OpenJS NodeJS Application Developer Study Guide
2+
layout: base.njk
33
---
4-
<!doctype html>
5-
<html lang="en">
6-
<head>
7-
<meta charset="utf-8">
8-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9-
<title>{{ title }}</title>
10-
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
11-
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.css">
12-
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.css">
13-
<link rel="stylesheet" href="{{ "/css/main.css" | url }}">
14-
<link rel="stylesheet"
15-
href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.16.2/build/styles/default.min.css">
16-
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.16.2/build/highlight.min.js"></script>
17-
<script>hljs.initHighlightingOnLoad();</script>
18-
</head>
19-
<body>
20-
<header class="container">
21-
<div class="row">
22-
<div class="column column-50">
23-
<h1 class="logo"><a href="/">ONAD Study Guide</a></h1>
24-
</div>
25-
<div class="top-links column column-50">
26-
<ul>
27-
<li><a href="https://training.linuxfoundation.org/certification/jsnad/" target="_blank" title="OpenJS Node.js Application Developer (JSNAD)">JSNAD Certification</a></li>
28-
</ul>
29-
</div>
30-
</div>
31-
</header>
32-
<main class="container">
33-
<div class="row">
34-
<div class="sidebar column">
35-
<nav>
36-
<ul>
37-
<li><a href="#" {% if page.url === '/buffer/' %} class="current" {% endif %}>Buffer and Streams</a></li>
38-
<li><a href="#">Control flow</a></li>
39-
<li><a href="#">Child Processes</a></li>
40-
<li><a href="#">Diagnostics</li>
41-
<li><a href="#">Error Handling</a></li>
42-
<li><a href="#">Node.js CLI</a></li>
43-
<li><a href="{{ "/events" | url }}" {% if page.url === '/events/' %} class="current" {% endif %}>Events</li>
44-
<li><a href="#">File System</a></li>
45-
<li><a href="#">JavaScript Prerequisites</a></li>
46-
<li><a href="#">Module system</a></li>
47-
<li><a href="#">Process/Operating System</a></li>
48-
<li><a href="#">Package.json</a></li>
49-
<li><a href="#">Unit Testing</a></li>
50-
</ul>
51-
</nav>
52-
</div>
53-
<div class="main-content column column-75">
54-
<h1>{{ title }}</h1>
554

56-
{{ content | safe }}
57-
</div>
58-
</div>
59-
</main>
60-
<footer class="container">
61-
<div class="row">
62-
<div class="column column-75 column-offset-25">
63-
<p><a href="https://github.com/Node-Study-Guide/openjs-nodejs-application-developer-study-guide/tree/master/{{ page.inputPath }}">Edit this page on GitHub</a></p>
64-
</div>
65-
</div>
66-
67-
</footer>
68-
</body>
69-
</html>
5+
<h1>{{ title }}</h1>
6+
7+
{{ content | safe }}

_includes/post.njk

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: base.njk
3+
templateClass: tmpl-post
4+
---
5+
6+
<h1>{{ title }}</h1>
7+
8+
<p class="metadata">
9+
<span class="author">Author: <a href="{{ authors[author].link | url }}">{{authors[author].name}}</a>
10+
</span>
11+
<br/>
12+
<time datetime="{{ date | dateIso }}">{{ date | dateReadable }}</time>
13+
</p>
14+
15+
{{ content | safe }}
16+
17+
<h3>Ready to mark {{title}} as completed?</h3>
18+
19+
<button onClick="toggleCompletedTopic('{{page.url}}')" data-topic="{{page.url}}" class="completed-button">Mark as completed</button>

buffers-and-streams/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: default.njk
2+
layout: default
33
title: Buffers and Streams
44
---
55

cheatsheet/index.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,53 @@
11
---
2-
layout: default.njk
2+
layout: default
33
title: Node Cheat Sheet
44
---
55

6+
## [Control Flow](#control-flow)
7+
8+
### Callback pattern
9+
10+
```
11+
function foo(val1, val2, callback) {
12+
...
13+
callback();
14+
}
15+
```
16+
17+
### Promise pattern
18+
19+
```
20+
function foo(ok) {
21+
return new Promise(resolve, reject) {
22+
if (ok) {
23+
resolve('success');
24+
} else {
25+
reject('boo');
26+
}
27+
}
28+
}
29+
30+
foo()
31+
.then(res => {
32+
console.log(res);
33+
})
34+
.catch(err => {
35+
throw err;
36+
})
37+
```
38+
39+
### Async/Await
40+
41+
```
42+
async function callFoo() {
43+
try {
44+
const result = await foo(true);
45+
} catch(err) {
46+
throw err;
47+
}
48+
}
49+
```
50+
651
## [Events](#events)
752

853
Class: events.EventEmitter

0 commit comments

Comments
 (0)