diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2018-04-21 05:41:16 +0300 |
---|---|---|
committer | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2018-04-24 10:30:21 +0300 |
commit | 6946812191862bfbcb12ab971694b5e2d76fee23 (patch) | |
tree | fab98bc04f4bbe69c1e8ae1f78402f9c33d1cc84 /doc/api/globals.md | |
parent | 982adb5994e940de68df5d71e2b88a3cf89f29d7 (diff) | |
download | android-node-v8-6946812191862bfbcb12ab971694b5e2d76fee23.tar.gz android-node-v8-6946812191862bfbcb12ab971694b5e2d76fee23.tar.bz2 android-node-v8-6946812191862bfbcb12ab971694b5e2d76fee23.zip |
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: https://github.com/nodejs/node/pull/20188
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/globals.md')
0 files changed, 0 insertions, 0 deletions