Niche Portobello Mushroom

    @putout/plugin-convert-for-each-to-for-of

    7.1.2 • Public • Published

    @putout/plugin-convert-for-each-to-for-of NPM version

    The forEach() method executes a provided function once for each array element.

    The for...of statement creates a loop which invokes a custom iteration hook with statements to be executed for the value of each element of an array.

    (c) MDN

    🐊Putout plugin adds ability to convert forEach() to for...of. Complements @putout/plugin-convert-const-to-let.

    Install

    npm i @putout/plugin-convert-for-each-to-for-of -D
    

    Rule

    {
        "rules": {
            "convert-for-each-to-for-of": "on"
        }
    }

    Example of incorrect code

    Object.keys(json).forEach((name) => {
        manage(name, json[name]);
    });
    
    [].forEach.call(arguments, (item) => {
        console.log(item);
    });

    Example of correct code

    for (const name of Object.keys(json)) {
        manage(name, json[name]);
    }
    
    for (const name of arguments) {
        console.log(item);
    }

    License

    MIT

    Install

    npm i @putout/plugin-convert-for-each-to-for-of

    DownloadsWeekly Downloads

    6,673

    Version

    7.1.2

    License

    MIT

    Unpacked Size

    8.42 kB

    Total Files

    4

    Last publish

    Collaborators

    • coderaiser