### Source Rewrite cleans up and reformats everything

        // Messy code with confusing and inconsistent indentations

    function bubbleSort    (list) {
    var items = list.slice(0), swapped =false,
            p,   q;
       for ( p= 1;p <   items.length; ++p) {
           for (q=0; q < items.length -    p; ++q) {
            if (items[q + 1  ] < items[q]) {
                swapped =true;
            let temp = items[q];
             items[q] = items[ q+1]; items[q+1] = temp;
                }
          }
            if (!swapped)
            break;
        }
           return items; alert("Finish");
    }

Ready.

Indent with: tab 2 spaces 4 spaces

String literal quotes: single (') double (") automatic

Rewriting is a two-step process: parse the code to get the syntax tree and then regenerate a new code from the syntax tree following the specified formatting.

Note: Only syntatically valid input is accepted.

Code regeneration is carried out using escodegen project.

Esprima is created and mantained by Ariya Hidayat.

- @Esprima
- GitHub