Gathering detailed insights and metrics for @intrnl/cv
Gathering detailed insights and metrics for @intrnl/cv
npm install @intrnl/cv
Typescript
Module System
Node Version
NPM Version
68.1
Supply Chain
98.1
Quality
75.3
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
1
Compared to previous week
Last month
-40%
3
Compared to previous month
Last year
-82.3%
85
Compared to previous year
Utility for constructing CSS class names based on variants.
Fast, almost drop-in replacement for cva
1import { cv } from '@intrnl/cv'; 2 3const button = cv('button', { 4 variants: { 5 variant: { 6 contained: 'button--variant-contained', 7 text: 'button--variant-text', 8 outlined: 'button--variant-outlined', 9 }, 10 color: { 11 primary: '', 12 error: '', 13 }, 14 rounded: { 15 true: 'button--rounded', 16 false: null, 17 }, 18 }, 19 defaultVariants: { 20 variant: 'text', 21 rounded: true, 22 }, 23 compoundVariants: [ 24 { 25 variant: 'contained', 26 color: 'primary', 27 className: 'button--contained-primary', 28 }, 29 ], 30});
These benchmark cases are taken from an actual project, your mileage may vary, however.
$ pnpm exec vite-node bench.js
cpu: AMD Ryzen 7 5700U with Radeon Graphics
runtime: node v19.5.0 (x64-linux)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
• paper
------------------------------------------------- -----------------------------
cv 276.99 ns/iter (263.84 ns … 497.04 ns) 283.44 ns 411.18 ns 497.04 ns
cva 4.63 µs/iter (4.58 µs … 4.83 µs) 4.64 µs 4.83 µs 4.83 µs
summary for paper
cv
16.72x faster than cva
• button
------------------------------------------------- -----------------------------
cv 16.18 µs/iter (12.43 µs … 3.46 ms) 14.95 µs 21.58 µs 23.89 µs
cva 114.82 µs/iter (95.12 µs … 4.17 ms) 104.55 µs 240.32 µs 345.43 µs
summary for button
cv
7.1x faster than cva
• iconButton
------------------------------------------------- -----------------------------
cv 6.03 µs/iter (5.94 µs … 6.34 µs) 6.03 µs 6.34 µs 6.34 µs
cva 15.66 µs/iter (13.2 µs … 2.8 ms) 15.22 µs 21.44 µs 22 µs
summary for iconButton
cv
2.6x faster than cva
• tableCell
------------------------------------------------- -----------------------------
cv 193.23 ns/iter (152.39 ns … 296.48 ns) 231.24 ns 249.35 ns 264.89 ns
cva 5.13 µs/iter (5.07 µs … 5.23 µs) 5.16 µs 5.23 µs 5.23 µs
summary for tableCell
cv
26.55x faster than cva
$ bun bench.js
cpu: AMD Ryzen 7 5700U with Radeon Graphics
runtime: bun 0.5.3 (x64-linux)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------- -----------------------------
• paper
------------------------------------------------- -----------------------------
cv 224.73 ns/iter (206.3 ns … 510.17 ns) 219.75 ns 354.1 ns 377.12 ns
cva 1.54 µs/iter (1.45 µs … 2.32 µs) 1.53 µs 2.32 µs 2.32 µs
summary for paper
cv
6.85x faster than cva
• button
------------------------------------------------- -----------------------------
cv 4.79 µs/iter (4.72 µs … 5.08 µs) 4.78 µs 5.08 µs 5.08 µs
cva 35.95 µs/iter (31.5 µs … 1.1 ms) 35.69 µs 73.47 µs 78.57 µs
summary for button
cv
7.51x faster than cva
• iconButton
------------------------------------------------- -----------------------------
cv 1.84 µs/iter (1.78 µs … 2.1 µs) 1.85 µs 2.1 µs 2.1 µs
cva 5.84 µs/iter (5.73 µs … 6.19 µs) 5.94 µs 6.19 µs 6.19 µs
summary for iconButton
cv
3.18x faster than cva
• tableCell
------------------------------------------------- -----------------------------
cv 241.61 ns/iter (222.3 ns … 406.55 ns) 232.96 ns 371.83 ns 383.27 ns
cva 1.04 µs/iter (988.56 ns … 1.28 µs) 1.05 µs 1.28 µs 1.28 µs
summary for tableCell
cv
4.32x faster than cva
No vulnerabilities found.
No security vulnerabilities found.