5 ms·
I think it's just for brevity, rather than because a helper is needed. OP listed the entire source code of their module in their comment.
by d1sxeyes 4y ago
I think it's just for brevity, rather than because a helper is needed. OP listed the entire source code of their module in their comment.
- moffkalast 4y agoBrevity is cool, but that's kind of like naming all your variables one letter chars for brevity. This is something every web dev will instantly know what it does: document.querySelectorAll('#rabbit .green').forEach(tag => { }) Whereas this is something nobody knows what the fuck it is because it's completely non-standard. for (const rabbit of dqsA('#rabbits .green')) { } And get what, 10 characters less in one row? Basically nothing.
- hombre_fatal 4y agofor/of vs .forEach isn't the issue here. Frankly I almost always use for/of because it's implemented for all iterators and I prefer being outside of a function (e.g. I can use await). All they did was alias `dqsA`. If anything, it's the fn name that could be better.
- d1sxeyes 4y agoIt’s no more ‘non-standard’ than jQuery’s `$`. Most IDEs will allow you to see what dqsA aliases by mousing over. I don’t really see a problem with it. It also looks like the kind of thing a pre-commit hook could trivially expand if you’re working with other people who might find it in some way unacceptable.