classix 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +31 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # classix
2
2
 
3
+ The [fastest](#comparison) and [tiniest](#comparison) utility for conditionally joining classNames.
4
+
3
5
  ## Installation
4
6
 
5
7
  ```bash
@@ -8,6 +10,8 @@ npm install classix
8
10
 
9
11
  ## Usage
10
12
 
13
+ Use any amount of string expressions and classix will join them like so:
14
+
11
15
  ```js
12
16
  import cx from "classix";
13
17
  // or
@@ -31,7 +35,7 @@ cx(true ? "class1" : "class2");
31
35
  cx("class1", false ? "class2" : "class3");
32
36
  // => "class1 class3"
33
37
 
34
- cx(...['class1', 'class2', 'class3']);
38
+ cx(...["class1", "class2", "class3"]);
35
39
  // => class1 class2 class3
36
40
 
37
41
  cx(
@@ -42,13 +46,35 @@ cx(
42
46
  // => "flex bg-primary-100 m-2 p-2" *assuming isPrimary is true and isLarge is false
43
47
  ```
44
48
 
49
+ ## Comparison
50
+
51
+ | | classix | clsx | classnames |
52
+ | ------------ | ------------------------------------------------ | --------------------------------------------- | --------------------------------------------------- |
53
+ | **Size** | [281B](https://bundlephobia.com/package/classix) | [330B](https://bundlephobia.com/package/clsx) | [454B](https://bundlephobia.com/package/classnames) |
54
+ | **Ops/s\*** | 29M | 28M | 7M |
55
+ | **Strings** | Yes | Yes | Yes |
56
+ | **Numbers** | Yes | Yes | Yes |
57
+ | **Booleans** | Yes | Yes | Yes |
58
+ | **Arrays** | Yes with spreading | Yes | Yes |
59
+ | **Objects** | No\*\* | Yes | Yes |
60
+
61
+ \*Operations per second on an AMD Ryzen 5 5600x
62
+
63
+ \*\*classix aims to provide the fastest and tiniest utility by ommiting the object API, which it considers less ergonomic than standard function arguments:
64
+
65
+ ```js
66
+ // 🚫
67
+ cx({ class1: isPrimary && isLarge, class2: !isPrimary || !isLarge });
68
+ // ✅
69
+ cx(isPrimary && isLarge ? "class1" : "class2");
70
+ ```
71
+
45
72
  ## Highlights
46
73
 
47
- - Fast
48
- - Under 1 kB minified & gzipped
49
- - Typed with TypeScript
50
- - Fully tested
74
+ - Fastest & tiniest
51
75
  - Zero dependencies
76
+ - Fully typed (with TypeScript)
77
+ - Fully tested
52
78
  - Follows [semantic versioning](https://semver.org/)
53
79
 
54
80
  ## Changelog
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "classix",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A tiny utility for conditionally joining classNames.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",