├── Chapter01
├── benchmark.html
├── chrome_performance.html
├── chrome_rendering.html
├── chrome_rendering_deferred.html
├── fake_library.js
├── jsperf_code.html
├── main.css
└── shader_editor.html
├── Chapter02
├── currying.js
├── generator.js
├── immutable.html
├── immutable.min.js
├── not_deep_copy.html
├── null_resources.html
├── safe_mutable.html
├── safe_state_module.js
└── todo_redux.html
├── Chapter03
├── arrow_functions.html
├── collections.html
├── custom_tooltip.html
├── dom.html
├── fetch.html
├── lib.js
├── lib2.js
├── modules.html
├── node
│ ├── app.js
│ └── server.js
├── other_changes.html
├── prototype_and_classes.html
├── reflection_proxy.html
├── server.js
└── variables.html
├── Chapter04
├── todo
│ ├── public
│ │ └── global.css
│ └── src
│ │ ├── App.svelte
│ │ ├── Todo.svelte
│ │ ├── main.js
│ │ ├── stores.js
│ │ └── todo_store.js
└── weather
│ ├── public
│ └── global.css
│ └── src
│ ├── App.svelte
│ ├── Dropdown.svelte
│ ├── WeatherInput.svelte
│ ├── WeatherOutput.svelte
│ ├── main.js
│ └── stores.js
├── Chapter05
├── bad_code.js
├── child.js
├── custom_transform.js
├── example.js
├── example.txt
├── first_fs.js
├── http_get.js
├── http_server.js
├── import_script.js
├── main.js
├── named_pipe.js
├── named_pipe_child.js
├── package.json
├── parent_child_pipe.js
├── read_file_stream.js
└── require_script.js
├── Chapter06
├── cluster
│ ├── main.js
│ └── package.json
├── datagram
│ ├── client.js
│ ├── main.js
│ ├── package.json
│ └── price.js
├── http2server
│ ├── basic.js
│ ├── package.json
│ ├── server.crt.pem
│ ├── server.js
│ ├── server.key.pem
│ └── static
│ │ ├── index.html
│ │ ├── main.css
│ │ └── main.js
├── local
│ ├── cache.js
│ ├── helper.js
│ ├── main.js
│ ├── package.json
│ └── send.js
├── main_worker.js
├── package.json
├── quic
│ ├── client.js
│ ├── main.js
│ └── package.json
└── worker.js
├── Chapter07
├── batch
│ ├── count.js
│ ├── input.txt
│ ├── main.js
│ ├── output.txt
│ ├── package.json
│ └── simple_readable.js
├── duplex
│ ├── main.js
│ └── package.json
├── generators
│ ├── generators.js
│ ├── package.json
│ └── temp.txt
├── harness
│ ├── client.js
│ ├── output.txt
│ ├── package.json
│ ├── server.js
│ └── writable_server.js
├── readable
│ ├── main.js
│ ├── output.txt
│ └── package.json
├── transform
│ ├── main.js
│ └── package.json
└── writable
│ ├── main.js
│ └── package.json
├── Chapter08
├── json
│ ├── jsonformat.json
│ ├── main.js
│ └── package.json
├── messagepack
│ ├── main.js
│ └── package.json
├── protobuf
│ ├── main.js
│ ├── package.json
│ └── test.proto
└── schema
│ ├── decoder.js
│ ├── encoder.js
│ ├── example.js
│ ├── helper.js
│ ├── main.js
│ ├── package.json
│ ├── test.json
│ └── test2.json
├── Chapter09
└── microserve
│ ├── cache.js
│ ├── main.js
│ ├── package.json
│ ├── publish
│ ├── first.md
│ ├── further
│ │ └── three.md
│ └── second.md
│ ├── template.js
│ └── template
│ ├── css
│ └── main.css
│ ├── html
│ ├── footer.html
│ ├── header.html
│ └── sidebar.html
│ └── main.html
├── Chapter10
├── cache.html
├── cache_shared.js
├── largeObject.js
├── mock_customer_data.js
├── shared.js
├── test.js
├── worker.html
├── worker.js
└── worker_to_shared.js
├── Chapter11
├── app.js
├── offline_storage
│ ├── OfflineCacheWorker.js
│ ├── index.html
│ ├── interactions.js
│ └── main.css
└── source
│ ├── BaseServiceWorker.js
│ ├── CacheServiceWorker.js
│ ├── handlers.js
│ ├── index.html
│ ├── interactions.js
│ ├── main.css
│ └── row.template
├── Chapter12
├── .circleci
│ └── config.yml
├── .gitignore
├── LICENSE
├── build
│ ├── rollup.config.js
│ └── rollup.sass.config.js
├── cache.js
├── main-sass.js
├── main.js
├── package.json
├── publish
│ ├── first.md
│ ├── further
│ │ └── three.md
│ └── second.md
├── template.js
├── template
│ ├── html
│ │ ├── footer.html
│ │ ├── header.html
│ │ └── sidebar.html
│ ├── main.html
│ └── stylesheets
│ │ └── main.scss
└── test
│ ├── cache.tester.js
│ ├── test_cache.txt
│ └── tests.test.js
├── Chapter13
├── c_index.html
├── extern.c
├── external.js
├── first.wat
├── fizzbuzz.c
├── hamming.c
├── hello_world.c
├── index.html
├── math.wat
├── sharing_resources.wat
├── sqltest
│ └── index.html
└── useless.wat
├── LICENSE
├── README.md
└── newfile1.txt
/Chapter01/benchmark.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Benchmark Code
9 |
10 |
54 |
55 |
--------------------------------------------------------------------------------
/Chapter01/chrome_performance.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
23 |
24 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/Chapter01/chrome_rendering.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
93 |
--------------------------------------------------------------------------------
/Chapter01/chrome_rendering_deferred.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
35 |
36 |
37 |
38 |
39 |
77 |
--------------------------------------------------------------------------------
/Chapter01/fake_library.js:
--------------------------------------------------------------------------------
1 | window.Library = {
2 | sum : function() {
3 | let sum = 0;
4 | for(let i = 0; i < 10000; i++) {
5 | sum += i;
6 | }
7 | return sum;
8 | },
9 | unusedItem : {
10 | item : 'this'
11 | },
12 | outerFun : function(run=false) {
13 | const innerFun = () => {
14 | let _i = Object.assign({}, this.unusedItem);
15 | let sumSum = 0;
16 | for(let i = 0; i < 10; i++) {
17 | sumSum += this.sum();
18 | }
19 | return sumSum;
20 | }
21 | if( run ) {
22 | return innerFun();
23 | } else {
24 | return 'nothin to run';
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Chapter01/jsperf_code.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
28 |
--------------------------------------------------------------------------------
/Chapter01/main.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin : 0;
3 | }
--------------------------------------------------------------------------------
/Chapter01/shader_editor.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
13 |
20 |
111 |
--------------------------------------------------------------------------------
/Chapter02/currying.js:
--------------------------------------------------------------------------------
1 | const add = function(a, b) {
2 | return function(b) {
3 | return a + b;
4 | }
5 | }
6 |
7 | console.log(add(2)(5), 'this will be 7');
8 | const add5 = add(5);
9 | console.log(add5(5), 'this will be 10');
10 |
11 | const fullFun = function(a, b, c) {
12 | console.log('a', a);
13 | console.log('b', b);
14 | console.log('c', c);
15 | }
16 |
17 | const tempFun = fullFun.bind(null, 2);
18 | setTimeout(() => {
19 | const temp2Fun = tempFun.bind(null, 3);
20 | setTimeout(() => {
21 | const temp3Fun = temp2Fun.bind(null, 5);
22 | setTimeout(() => {
23 | console.log('temp3Fun');
24 | temp3Fun();
25 | }, 1000);
26 | }, 1000);
27 | console.log('temp2Fun');
28 | temp2Fun(5)
29 | }, 1000);
30 | console.log('tempFun');
31 | tempFun(3, 5);
32 |
33 | const calculateArbitraryValueWithPrecision = function(prec=0, val) {
34 | return function(val) {
35 | return parseFloat((val / 1000).toFixed(prec));
36 | }
37 | }
38 |
39 | const arr = new Array(50000);
40 | for(let i = 0; i < arr.length; i++) {
41 | arr[i] = i + 1000;
42 | }
43 |
44 | console.log(arr.map(calculateArbitraryValueWithPrecision(2)));
--------------------------------------------------------------------------------
/Chapter02/generator.js:
--------------------------------------------------------------------------------
1 | const simpleGenerator = function* () {
2 | let it = 0;
3 | for(;;) {
4 | yield it;
5 | it++;
6 | }
7 | }
8 |
9 | const sg = simpleGenerator();
10 | for(let i = 0; i < 10; i++) {
11 | console.log(sg.next().value);
12 | }
13 | sg.return();
14 |
15 | console.log(sg.next().value);
16 |
17 | const timing = function*(time) {
18 | yield Date.now() - time;
19 | }
20 |
21 | const time = timing(Date.now());
22 | let sum = 0;
23 | for(let i = 0; i < 1000000; i++) {
24 | sum = sum + i;
25 | }
26 | console.log(time.next().value);
27 |
28 | const nums = function*(fn=null) {
29 | let i = 0;
30 | for(;;) {
31 | yield i;
32 | if( fn ) {
33 | i += fn(i);
34 | } else {
35 | i += 1;
36 | }
37 | }
38 | }
39 |
40 | const data = [];
41 | for(let i in nums()) {
42 | if( i > 100 ) {
43 | break;
44 | }
45 | data.push(i);
46 | }
47 |
48 | console.log('data', data);
49 |
50 | const nums = function*(fn=null) {
51 | let i = 0;
52 | for(;;) {
53 | yield i;
54 | if( fn ) {
55 | i += fn(i);
56 | } else {
57 | i += 1;
58 | }
59 | }
60 | }
61 |
62 | const data = [];
63 | const gen = nums();
64 | for(let i of gen) {
65 | console.log(i);
66 | if( i > 100 ) {
67 | break;
68 | }
69 | data.push(i);
70 | }
71 |
72 | const fakestream = function*(data) {
73 | const chunkSize = 10;
74 | const dataLength = data.length;
75 | let i = 0;
76 | while(i < dataLength ) {
77 | const outData = [];
78 | for(let j = 0; j < chunkSize; j++) {
79 | outData.push(data[i]);
80 | i+=1;
81 | }
82 | yield outData;
83 | }
84 | }
85 |
86 | for(let i of fakestream(data)) {
87 | console.log(i);
88 | }
89 |
90 | const trampoline = fun => {
91 | return (...arguments) => {
92 | let result = fun(...arguments);
93 | while( typeof result === 'function' ) {
94 | result = result();
95 | }
96 |
97 | return result;
98 | }
99 | }
100 |
101 | const _d = new Array(100000);
102 | for(let i = 0; i < _d.length; i++) {
103 | _d[i] = i;
104 | }
105 |
106 | const recurseSummer = function(data, sum=0) {
107 | if(!data.length) {
108 | return sum;
109 | }
110 | return () => recurseSummer(data.slice(1), sum + data[0]);
111 | }
112 |
113 | const recurseFilter = function(data, con, filtered=[]) {
114 | if(!data.length) {
115 | return filtered;
116 | }
117 | return () => recurseFilter(data.slice(1),con, con(data[0]) ? filtered.length ? new Array(...filtered, data[0]) : [data[0]] : filtered);
118 | }
119 |
120 | const finalFilter = trampoline(recurseFilter);
121 | console.log(finalFilter(_d, item => item % 2 === 0));
--------------------------------------------------------------------------------
/Chapter02/immutable.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
100 |
101 |