Re:Show HN: Alter – convert text/code to an image
by nunull on Saturday November 26, 2016 @06:53AM
(#13043057)
Regarding 1: I think the sorting approach is actually really nice in this case. Clearly it's not as efficient as a simple loop, but it's safer and more readable. Explicit looping and mutation can introduce nasty bugs which this kind of declarative approach can't.
[ Parent
| on HN ]
Re:Show HN: Alter – convert text/code to an image
by madflame991 on Saturday November 26, 2016 @08:35AM
(#13043424)
No need to mutate/slice/sort anything
Math.max(...lines.map((line) => ctx.measureText(line).width))