lukeed/clsxPublic

A tiny (239B) utility for constructing `className` strings conditionally.

increase perf && smaller size #23

ClosedXaveScorclosed 4 commits intomasterfromrefs/pull/23/head
ConversationFiles changed
2 files changed+13-6
StackedSplit
src/index.js+8 −6

This is a regression. Number type is returned.

src/index.js:5head35deeaa
Author

Added tests for this case. I found this is not regression :-) Because https://github.com/lukeed/clsx/blob/master/src/index.js#L35 converts `toVal` return value to string.

src/index.js:5head35deeaa

Why did these vars get swapped?

src/index.js:10head35deeaa
Author

Codebase contains ``` str && (str += ' '); str += k; ``` thrice. I try to create more identical pieces of code for better work for the "deflate" algorithm. This trick saves 2 bytes of gzip size. I don't rename the third piece(https://github.com/lukeed/clsx/blob/master/src/index.js#L34) because the total size not changed.

src/index.js:10head35deeaa
test/index.js+5 −0