Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: modernize and optimize doc/addon-verify.js #20188

Closed
wants to merge 1 commit into from
Closed

tools: modernize and optimize doc/addon-verify.js #20188

wants to merge 1 commit into from

Commits on Apr 21, 2018

  1. tools: modernize and optimize doc/addon-verify.js

    Modernize:
    * Replace `var` with `const` / `let`.
    * Replace common functions with arrow functions.
    * Use destructuring.
    * Use spread, eliminate `arguments`.
    * 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()`.
    * Rename confusingly similar variables.
    
    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.
    vsemozhetbyt committed Apr 21, 2018
    Configuration menu
    Copy the full SHA
    8510b9d View commit details
    Browse the repository at this point in the history