MCPcopy
hub / github.com/mishoo/UglifyJS / patch_for_init

Function patch_for_init

lib/compress.js:2092–2110  ·  view source on GitHub ↗
(node, in_list)

Source from the content-addressed store, hash-verified

2090 // https://github.com/mishoo/UglifyJS/issues/3371
2091 // We fix it at this stage by moving the `var` outside the `for`.
2092 function patch_for_init(node, in_list) {
2093 var block;
2094 if (node.init instanceof AST_BlockStatement) {
2095 block = node.init;
2096 node.init = block.body.pop();
2097 block.body.push(node);
2098 }
2099 if (node.init instanceof AST_Defun) {
2100 if (!block) block = make_node(AST_BlockStatement, node, { body: [ node ] });
2101 block.body.splice(-1, 0, node.init);
2102 node.init = null;
2103 } else if (node.init instanceof AST_SimpleStatement) {
2104 node.init = node.init.body;
2105 } else if (is_empty(node.init)) {
2106 node.init = null;
2107 }
2108 if (!block) return;
2109 return in_list ? List.splice(block.body) : block;
2110 }
2111
2112 function tighten_body(statements, compressor) {
2113 var in_lambda = last_of(compressor, function(node) {

Callers 2

remove_candidateFunction · 0.85
compress.jsFile · 0.85

Calls 2

make_nodeFunction · 0.85
is_emptyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…