Skip to content

Commit da32273

Browse files
authored
Merge branch 'master' into buffersAndStreams
2 parents 49cb957 + 2cf9010 commit da32273

File tree

15 files changed

+599
-33
lines changed

15 files changed

+599
-33
lines changed

.eleventy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = function(eleventyConfig) {
1515
eleventyConfig.addPassthroughCopy("js");
1616
eleventyConfig.addPassthroughCopy("CNAME");
1717
eleventyConfig.addLayoutAlias("default", "default.njk");
18+
eleventyConfig.addLayoutAlias("post", "post.njk");
1819
return {
1920
passthroughFileCopy: true
2021
};

.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/topics.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"title": "Buffer and Streams",
4-
"url": "/buffer-and-streams/"
3+
"title": "Buffers and Streams",
4+
"url": "/buffers-and-streams/"
55
},
66
{
77
"title": "Control flow",

_includes/default.njk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
layout: base.njk
3-
templateClass: tmpl-post
43
---
54

65
<h1>{{ title }}</h1>

cheatsheet/index.md

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

@@ -35,6 +35,51 @@ buf.length
3535
buf.toString([encoding[, start[, end]]])
3636
buf.values()
3737
buf.write(string[, offset[, length]][, encoding])
38+
39+
## [Control Flow](#control-flow)
40+
41+
### Callback pattern
42+
43+
```
44+
function foo(val1, val2, callback) {
45+
...
46+
callback();
47+
}
48+
```
49+
50+
### Promise pattern
51+
52+
```
53+
function foo(ok) {
54+
return new Promise(resolve, reject) {
55+
if (ok) {
56+
resolve('success');
57+
} else {
58+
reject('boo');
59+
}
60+
}
61+
}
62+
63+
foo()
64+
.then(res => {
65+
console.log(res);
66+
})
67+
.catch(err => {
68+
throw err;
69+
})
70+
```
71+
72+
### Async/Await
73+
74+
```
75+
async function callFoo() {
76+
try {
77+
const result = await foo(true);
78+
} catch(err) {
79+
throw err;
80+
}
81+
}
82+
3883
```
3984
4085
## [Events](#events)

child-processes/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: Child Processes
44
---
55

0 commit comments

Comments
 (0)