src/index.js
function Handle_forEach(t, path, aggressive_optimization, possible_undefined) {
	var arrayName = path.scope.generateUidIdentifier("a"),
		funcName = path.scope.generateUidIdentifier("f"),
		iterator = path.scope.generateUidIdentifier("i"),
		call = t.expressionStatement (
			t.callExpression(funcName, [
				t.memberExpression (
					arrayName,
					iterator,
					true
				),
				iterator,
				arrayName
			])
		)

	path.getStatementParent().insertBefore ([
		t.variableDeclaration("let", [
			t.variableDeclarator (
				arrayName,
				path.node.callee.object
			)
		]),

		t.variableDeclaration("let", [
			t.variableDeclarator (
				funcName,
				path.node.arguments[0]
			)
		]),

		aggressive_optimization
			? t.forStatement (
				t.variableDeclaration("let", [
					t.variableDeclarator (
						iterator,
						t.memberExpression (
							arrayName,
							t.identifier("length")
						)
					)
				]),
				possible_undefined
					? t.logicalExpression (
						"&&",
						t.updateExpression("--", iterator),
						t.binaryExpression (
							"!==",
							t.memberExpression (
								arrayName,
								iterator,
								true
							),
							t.identifier("undefined")
						)
					)
					: t.updateExpression("--", iterator),
				null,
				call
			)
			: t.forStatement (
				t.variableDeclaration("let", [
					t.variableDeclarator (
						iterator,
						t.numericLiteral(0)
					)
				]),
				possible_undefined
					? t.logicalExpression (
						"&&",
						t.binaryExpression (
							"<",
							iterator,
							t.memberExpression (
								arrayName,
								t.identifier("length")
							)
						),
						t.binaryExpression (
							"!==",
							t.memberExpression (
								arrayName,
								iterator,
								true
							),
							t.identifier("undefined")
						)
					)
					: t.updateExpression("--", iterator),
				t.updateExpression("++", iterator),
				call
			)
	])

	path.remove()
}
function Handle_forEach(t, path, aggressive_optimization, possible_undefined) {
	var arrayName = path.scope.generateUidIdentifier("a"),
		funcName = path.scope.generateUidIdentifier("f"),
		iterator = path.scope.generateUidIdentifier("i"),
		call = t.expressionStatement (
			t.callExpression(funcName, [
				t.memberExpression (
					arrayName,
					iterator,
					true
				),
				iterator,
				arrayName
			])
		)

	path.getStatementParent().insertBefore ([
		t.variableDeclaration("let", [
			t.variableDeclarator (
				arrayName,
				path.node.callee.object
			)
		]),

		t.variableDeclaration("let", [
			t.variableDeclarator (
				funcName,
				path.node.arguments[0]
			)
		]),

		aggressive_optimization
			? t.forStatement (
				t.variableDeclaration("let", [
					t.variableDeclarator (
						iterator,
						t.memberExpression (
							arrayName,
							t.identifier("length")
						)
					)
				]),
				possible_undefined
					? t.logicalExpression (
						"&&",
						t.updateExpression("--", iterator),
						t.binaryExpression (
							"!==",
							t.memberExpression (
								arrayName,
								iterator,
								true
							),
							t.identifier("undefined")
						)
					)
					: t.updateExpression("--", iterator),
				null,
				call
			)
			: t.forStatement (
				t.variableDeclaration("let", [
					t.variableDeclarator (
						iterator,
						t.numericLiteral(0)
					)
				]),
				possible_undefined
					? t.logicalExpression (
						"&&",
						t.binaryExpression (
							"<",
							iterator,
							t.memberExpression (
								arrayName,
								t.identifier("length")
							)
						),
						t.binaryExpression (
							"!==",
							t.memberExpression (
								arrayName,
								iterator,
								true
							),
							t.identifier("undefined")
						)
					)
					: t.updateExpression("--", iterator),
				t.updateExpression("++", iterator),
				call
			)
	])

	path.remove()
}
function Handle_forEach ( t , path , aggressive_optimization , possible_undefined ) { var arrayName = path . scope . generateUidIdentifier ( "a" ) , funcName = path . scope . generateUidIdentifier ( "f" ) , iterator = path . scope . generateUidIdentifier ( "i" ) , call = t . expressionStatement ( t . callExpression ( funcName , [ t . memberExpression ( arrayName , iterator , true ) , iterator , arrayName ] ) ) path . getStatementParent ( ) . insertBefore ( [ t . variableDeclaration ( "let" , [ t . variableDeclarator ( arrayName , path . node . callee . object ) ] ) , t . variableDeclaration ( "let" , [ t . variableDeclarator ( funcName , path . node . arguments [ 0 ] ) ] ) , aggressive_optimization ? t . forStatement ( t . variableDeclaration ( "let" , [ t . variableDeclarator ( iterator , t . memberExpression ( arrayName , t . identifier ( "length" ) ) ) ] ) , possible_undefined ? t . logicalExpression ( "&&" , t . updateExpression ( "--" , iterator ) , t . binaryExpression ( "!==" , t . memberExpression ( arrayName , iterator , true ) , t . identifier ( "undefined" ) ) ) : t . updateExpression ( "--" , iterator ) , null , call ) : t . forStatement ( t . variableDeclaration ( "let" , [ t . variableDeclarator ( iterator , t . numericLiteral ( 0 ) ) ] ) , possible_undefined ? t . logicalExpression ( "&&" , t . binaryExpression ( "<" , iterator , t . memberExpression ( arrayName , t . identifier ( "length" ) ) ) , t . binaryExpression ( "!==" , t . memberExpression ( arrayName , iterator , true ) , t . identifier ( "undefined" ) ) ) : t . updateExpression ( "--" , iterator ) , t . updateExpression ( "++" , iterator ) , call ) ] ) path . remove ( ) }
NON-RETURNING
NON - RETURNING