Mirror: The magical sticky regex-based parser generator 🧙
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Simplify output of astExpression(...) generator

+6 -19
+1 -1
src/babel/__snapshots__/plugin.test.js.snap
··· 114 114 loop_3: for (var j3 = 0; 1; j3++) { 115 115 var y3 = state.y; 116 116 117 - if (!_exec(state, _node_expression3)) { 117 + if (x = _exec(state, _node_expression3)) {} else { 118 118 if (j3) { 119 119 state.y = y3; 120 120 break loop_3;
+5 -18
src/codegen.js
··· 30 30 const restoreLength = 31 31 (opts.length && opts.abort && js`${_node}.length = ln${opts.length};`) || 32 32 ''; 33 - 34 - const abort = js` 35 - ${opts.onAbort} 36 - ${restoreIndex(opts.index)} 37 - ${restoreLength} 38 - ${opts.abort} 39 - `; 40 - 41 33 const expression = ast.expression.fn 42 34 ? `${ast.expression.id}(${_state})` 43 35 : `${_exec}(${_state}, ${ast.expression.id})`; 44 36 45 - if (!opts.capture) { 46 - return js` 47 - if (!${expression}) { 48 - ${abort} 49 - } 50 - `; 51 - } 52 - 53 37 return js` 54 38 if (${_match} = ${expression}) { 55 - ${_node}.push(${_match}); 39 + ${opts.capture ? js`${_node}.push(${_match})` : ''} 56 40 } else { 57 - ${abort} 41 + ${opts.onAbort} 42 + ${restoreIndex(opts.index)} 43 + ${restoreLength} 44 + ${opts.abort} 58 45 } 59 46 `; 60 47 };