clsx
2.1.1 · 23 Apr 2024MIT179.1M / weekRepositoryHomepagenpmAtom feed
1.2.1 is the newest release of 1.x.
In short
2 faster2 fixed7 internal
Release note
Note: This is a performance-related patch only!Across all benchmarks, this version of
clsxis ~1M ops/sec faster thanclsx@1.1.0....It also happens to be 1 byte (gzip) smaller 😅🎉
Patches
Remove needless spacer on string/number condition: ff11464
Remove unnecessary recursive caller for object keys: f43dd23
Guard all
toValcalls with truthy assertions: 4fa8811, 019ec02Reorder
typeofchecks for common case: 08a5a7f
Benchmarks
Run on Node.js v10.13.0.You may find updated browser benchmarks here.
The snippet below is comparing clsx@1.1.1 (this version) to the previous version, and to classnames for ballpark comparison. All candidates are functionally identical!
# Strings classnames x 3,992,284 ops/sec ±1.64% (94 runs sampled) clsx@1.1.0 x 11,253,372 ops/sec ±0.35% (96 runs sampled) clsx@1.1.1 x 12,784,134 ops/sec ±0.42% (97 runs sampled) # Objects classnames x 3,772,978 ops/sec ±0.46% (96 runs sampled) clsx@1.1.0 x 7,288,178 ops/sec ±0.31% (96 runs sampled) clsx@1.1.1 x 9,412,010 ops/sec ±0.42% (95 runs sampled) # Arrays classnames x 1,665,275 ops/sec ±1.83% (93 runs sampled) clsx@1.1.0 x 8,340,174 ops/sec ±0.53% (96 runs sampled) clsx@1.1.1 x 9,141,916 ops/sec ±0.42% (95 runs sampled) # Nested Arrays classnames x 1,164,706 ops/sec ±1.60% (95 runs sampled) clsx@1.1.0 x 6,284,485 ops/sec ±0.58% (90 runs sampled) clsx@1.1.1 x 7,165,151 ops/sec ±0.47% (91 runs sampled) # Nested Arrays w/ Objects classnames x 1,597,180 ops/sec ±1.49% (93 runs sampled) clsx@1.1.0 x 6,345,248 ops/sec ±0.21% (95 runs sampled) clsx@1.1.1 x 7,651,411 ops/sec ±0.56% (95 runs sampled) # Mixed classnames x 2,129,199 ops/sec ±1.46% (94 runs sampled) clsx@1.1.0 x 6,557,515 ops/sec ±0.73% (91 runs sampled) clsx@1.1.1 x 8,119,210 ops/sec ±0.42% (93 runs sampled) # Mixed (Bad Data) classnames x 1,166,577 ops/sec ±0.84% (94 runs sampled) clsx@1.1.0 x 2,018,654 ops/sec ±0.15% (98 runs sampled) clsx@1.1.1 x 2,238,939 ops/sec ±0.34% (95 runs sampled)
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.