Closed jonathanglasmeyer closed 8 years ago
100.00%
Merging #58 into master will not affect coverage as of
f6e166e
@@ master #58 diff @@
======================================
Files 34 34
Stmts 285 264 -21
Branches 0 0
Methods 0 0
======================================
- Hit 285 264 -21
Partial 0 0
Missed 0 0
Review entire Coverage Diff as of
f6e166e
Powered by Codecov. Updated on successful CI builds.
So i got an itch to play around with the @kentcdodds stats implementation from yesterday. Although I agree that reducing can lead to elegant code, something with the pattern of returning string constants bugs me, it seems such a "non-standard" way of doing things. So, without having any serious intention of wanting to change this, i had to try out if there is a different way to express the inherent logic. I found that using lodash
find
is pretty nice for the case of multiple validators. Just have a look. We can totally throw this branch away if we don't like this, but maybe it's an inspiration or whatever. ;)I personally think that the cognitive load is decreased writing it like this, it feels more declarative whereas the CONTINUE / BREAK implementation feels a little imperative to me. I particulary like using the
undefined
return value of passing validators instead of explicitly returningCONTINUE
every time.Have a nice saturday!