Skip to content

Commit ebff10b

Browse files
committed
Go over Chapter 21
Use promises, components and fetch for client side, headers for long polling.
1 parent 042d62c commit ebff10b

File tree

13 files changed

+864
-1162
lines changed

13 files changed

+864
-1162
lines changed

06_object.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,17 @@ inconvenient when you want to save a non-function value in there—but
370370
you can still create such properties by directly manipulating the
371371
prototype after you've defined the class.
372372

373+
Like `function`, `class` can be used both in statement and in
374+
expression positions. When used as an expression, it doesn't define a
375+
binding, but just produces the class as a value. The class name can be
376+
omitted in that case.
377+
378+
```
379+
let object = (new class { getWord() { return "hello"; } });
380+
console.log(object.getWord());
381+
// → hello
382+
```
383+
373384
## Overriding derived properties
374385

375386
{{index "shared property", overriding}}

09_regexp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,10 @@ are optional and taken to be zero when not given.
404404
{{index "getTime method"}}
405405

406406
Timestamps are stored as the number of milliseconds since the start of
407-
1970, using negative numbers for times before 1970 (following a
408-
convention set by “((Unix time))”, which was invented around that
409-
time). The `getTime` method on a date object returns this number. It
410-
is big, as you can imagine.
407+
1970, in the UTC ((time zone)), using negative numbers for times
408+
before 1970 (following a convention set by “((Unix time))”, which was
409+
invented around that time). The `getTime` method on a date object
410+
returns this number. It is big, as you can imagine.
411411

412412
```
413413
console.log(new Date(2013, 11, 19).getTime());

13_browser.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ A short HTML document might look like this:
184184
<!doctype html>
185185
<html>
186186
<head>
187-
<meta charset="utf8">
187+
<meta charset="utf-8">
188188
<title>My home page</title>
189189
</head>
190190
<body>
@@ -270,7 +270,7 @@ The following document will be treated just like the one shown previously:
270270

271271
```{lang: "text/html"}
272272
<!doctype html>
273-
<meta charset=utf8>
273+
<meta charset=utf-8>
274274
275275
<title>My home page</title>
276276

20_node.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ $ node
114114
$
115115
```
116116

117-
{{index "process object", "global scope", [variable, global], "exit method", "status code"}}
117+
{{index "process object", "global scope", [binding, global], "exit method", "status code"}}
118118

119-
The `process` variable, just like the `console` variable, is available
119+
The `process` binding, just like the `console` binding, is available
120120
globally in Node. It provides various ways to inspect and manipulate
121121
the current program. The `exit` method ends the process and can be
122122
given an exit status code, which tells the program that started `node`
@@ -136,9 +136,9 @@ $ node showargv.js one --and two
136136
["node", "/tmp/showargv.js", "one", "--and", "two"]
137137
```
138138

139-
{{index [variable, global]}}
139+
{{index [binding, global]}}
140140

141-
All the ((standard)) JavaScript global variables, such as `Array`,
141+
All the ((standard)) JavaScript global bindings, such as `Array`,
142142
`Math`, and `JSON`, are also present in Node's environment.
143143
Browser-related functionality, such as `document` and `prompt`, is
144144
absent.
@@ -147,7 +147,7 @@ absent.
147147

148148
{{index "Node.js", "global scope", "module loader"}}
149149

150-
Beyond the few variables I mentioned, such as `console` and `process`,
150+
Beyond the few bindings I mentioned, such as `console` and `process`,
151151
Node puts little functionality in the global scope. If you want to
152152
access built-in functionality, you have to ask the module system for
153153
it.
@@ -501,7 +501,7 @@ request to your server. It will respond with a small HTML page.
501501

502502
The function passed as argument to `createServer` is called every time
503503
a client connects to the server. The `request` and `response`
504-
variables are objects representing the incoming and outgoing data. The
504+
bindings are objects representing the incoming and outgoing data. The
505505
first contains information about the ((request)), such as its `url`
506506
property, which tells us to what URL the request was made.
507507

@@ -622,8 +622,8 @@ one piece at a time, rather than in one shot as with `writeFile`.
622622
{{index "createServer function", "request function", "event handling", "readable stream"}}
623623

624624
Readable ((stream))s are a little more involved. Both the `request`
625-
variable that was passed to the HTTP server's callback function and
626-
the `response` variable passed to the HTTP client are readable
625+
binding that was passed to the HTTP server's callback function and
626+
the `response` binding passed to the HTTP client are readable
627627
streams. (A server reads requests and then writes responses, whereas a
628628
client first writes a request and then reads a response.) Reading from
629629
a stream is done using event handlers, rather than methods.
@@ -661,7 +661,7 @@ createServer((request, response) => {
661661

662662
{{index "Buffer class", "toString method"}}
663663

664-
The `chunk` variable passed to the data handler will be a binary
664+
The `chunk` value passed to the data handler will be a binary
665665
`Buffer`. We can convert this to string by decoding it as UTF-8
666666
encoded characters with its `toString` method..
667667

@@ -791,13 +791,13 @@ decodes that to get rid of the `%20`-style escape codes, and resolves
791791
it relative to the program's working directory.
792792

793793
```{includeCode: ">code/file_server.js"}
794-
const {parse: parseURL} = require("url");
794+
const {parse} = require("url");
795795
const {resolve} = require("path");
796796
797797
const baseDirectory = process.cwd() + "/";
798798
799799
function urlPath(url) {
800-
let {pathname} = parseURL(url);
800+
let {pathname} = parse(url);
801801
let path = resolve(decodeURIComponent(pathname).slice(1));
802802
if (!path.startsWith(baseDirectory)) {
803803
throw {status: 403, body: "Forbidden"};

0 commit comments

Comments
 (0)