Closed ezhlobo closed 5 years ago
Hey,
Now when I'm passing basic each it transpiles into a monster:
each item in [1, 2, 3] div(key=item)= item
((_pug_nodes, _pug_arr) => { if (!(_pug_arr == null || Array.isArray(_pug_arr))) throw new Error( 'Expected "[1, 2, 3]" to be an array because it is passed to each.' ); if (_pug_arr == null || _pug_arr.length === 0) return undefined; for (let _pug_index = 0; _pug_index < _pug_arr.length; _pug_index++) { const item = _pug_arr[_pug_index]; _pug_nodes[_pug_nodes.length] = <div key={"pug" + item + ":0"}>{item}</div>; } return _pug_nodes; })([], [1, 2, 3]);
What do you think if we eliminate all these validations and return simple .map:
.map
[1, 2, 3].map((item) => ( <div key={"pug" + item + ":0"}>{item}</div> ))
And then even into something with initial keys:
[1, 2, 3].map((item) => ( <div key={item}>{item}</div> ))
//CC @ForbesLindesay
https://esbench.com/bench/5a295e6299634800a0349500
Done in v7.0.0
Hey,
Now when I'm passing basic each it transpiles into a monster:
What do you think if we eliminate all these validations and return simple
.map
:And then even into something with initial keys:
Why?
//CC @ForbesLindesay