|
1 function add(a, b, k) { |
|
2 var result = a + b; |
|
3 return k(result); |
|
4 } |
|
5 |
|
6 function sub(a, b, k) { |
|
7 var result = a - b; |
|
8 return k(result); |
|
9 } |
|
10 |
|
11 function mul(a, b, k) { |
|
12 var result = a * b; |
|
13 return k(result); |
|
14 } |
|
15 |
|
16 function div(a, b, k) { |
|
17 var result = a / b; |
|
18 return k(result); |
|
19 } |
|
20 |
|
21 function arithmetic() { |
|
22 add(4, 4, function (a) { |
|
23 // 8 |
|
24 sub(a, 2, function (b) { |
|
25 // 6 |
|
26 mul(b, 3, function (c) { |
|
27 // 18 |
|
28 div(c, 2, function (d) { |
|
29 // 9 |
|
30 console.log(d); |
|
31 }); |
|
32 }); |
|
33 }); |
|
34 }); |
|
35 } |
|
36 |
|
37 // Compile with closure compiler and the following flags: |
|
38 // |
|
39 // --compilation_level WHITESPACE_ONLY |
|
40 // --source_map_format V3 |
|
41 // --create_source_map code_math.map |
|
42 // --js_output_file code_math.min.js |
|
43 // |
|
44 // And then append the sourceMappingURL comment directive to code_math.min.js |
|
45 // manually. |