npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@intrnl/cv

v0.1.3

Published

Utility for constructing CSS class names based on variants

Downloads

5

Readme

cv

Utility for constructing CSS class names based on variants.

Fast, almost drop-in replacement for cva

import { cv } from '@intrnl/cv';

const button = cv('button', {
	variants: {
		variant: {
			contained: 'button--variant-contained',
			text: 'button--variant-text',
			outlined: 'button--variant-outlined',
		},
		color: {
			primary: '',
			error: '',
		},
		rounded: {
			true: 'button--rounded',
			false: null,
		},
	},
	defaultVariants: {
		variant: 'text',
		rounded: true,
	},
	compoundVariants: [
		{
			variant: 'contained',
			color: 'primary',
			className: 'button--contained-primary',
		},
	],
});

Benchmarks

These benchmark cases are taken from an actual project, your mileage may vary, however.

Node.js 19.5.0 / V8

$ 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 0.5.3 / JavaScriptCore

$ 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