Commit b5584c4
tools: modernize and optimize doc/addon-verify.js
Modernize:
* Replace `var` with `const` / `let`.
* Replace common functions with arrow functions.
* Use destructuring.
* Use `String.prototype.padStart()`, `String.prototype.endsWith()`.
Optimize:
* Reduce function calls.
* Reduce intermediate variables.
* Cache retrieved object properties.
* Move RegExp declaration out of a cycle.
* Simplify RegExps.
* Replace RegExp with string when string suffices.
* Remove conditions that cannot be false.
* Replace for..in with `Object.keys().forEach()`.
Also, eliminate needlessly complicated function chains:
* `ondone` callback only checks errors;
* if there is an error, it is called once and throws, then script exits;
* if there are no errors, it is noop;
* so there is no need to wrap it into `once()` function
* and there is no need to call it without errors;
* we can eliminate it and replace with `throw` where an error occurs;
* we can also replace `onprogress` callback with `console.log` in place;
* at last, we can eliminate `waiting` counter and `once()` utility.
The new script produces results identical to the old ones.
PR-URL: #20188
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent 9eacd66 commit b5584c4Copy full SHA for b5584c4
File tree
Expand file treeCollapse file tree
1 file changed
+37
-61
lines changedOpen diff view settings
Filter options
- tools/doc
Expand file treeCollapse file tree
1 file changed
+37
-61
lines changedOpen diff view settings
Collapse file
+37-61Lines changed: 37 additions & 61 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | 2 | |
3 | | - |
4 | | - |
5 | | - |
| 3 | + |
| 4 | + |
| 5 | + |
6 | 6 | |
7 | | - |
8 | | - |
9 | | - |
| 7 | + |
| 8 | + |
| 9 | + |
10 | 10 | |
11 | | - |
12 | | - |
13 | | - |
| 11 | + |
| 12 | + |
14 | 13 | |
15 | | - |
16 | 14 | |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
24 | 21 | |
25 | | - |
26 | | - |
| 22 | + |
| 23 | + |
27 | 24 | |
28 | | - |
| 25 | + |
29 | 26 | |
30 | 27 | |
31 | 28 | |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | 29 | |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
48 | 36 | |
49 | | - |
50 | 37 | |
51 | | - |
52 | | - |
| 38 | + |
| 39 | + |
53 | 40 | |
54 | 41 | |
55 | 42 | |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
| 43 | + |
| 44 | + |
61 | 45 | |
62 | | - |
| 46 | + |
63 | 47 | |
64 | 48 | |
65 | | - |
| 49 | + |
66 | 50 | |
67 | 51 | |
68 | 52 | |
| ||
73 | 57 | |
74 | 58 | |
75 | 59 | |
76 | | - |
| 60 | + |
77 | 61 | |
78 | 62 | |
79 | 63 | |
80 | 64 | |
81 | 65 | |
82 | 66 | |
83 | | - |
| 67 | + |
84 | 68 | |
85 | 69 | |
86 | 70 | |
87 | 71 | |
88 | 72 | |
89 | | - |
90 | | - |
91 | | - |
| 73 | + |
92 | 74 | |
93 | 75 | |
94 | 76 | |
95 | 77 | |
96 | 78 | |
97 | | - |
| 79 | + |
98 | 80 | |
99 | 81 | |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
| 82 | + |
| 83 | + |
104 | 84 | |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
| 85 | + |
109 | 86 | |
110 | | - |
111 | | - |
| 87 | + |
112 | 88 | |
113 | 89 | |
114 | 90 | |
|
0 commit comments