classix 1.2.1 → 2.0.1

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.
package/README.md CHANGED
@@ -48,25 +48,21 @@ cx(
48
48
 
49
49
  ## Comparison
50
50
 
51
- | | classix | clsx | classnames |
52
- | ------------ | ------------------------------------------------ | --------------------------------------------- | --------------------------------------------------- |
53
- | **Size** | [277B](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 |
51
+ ![Size comparison chart](media/size.png)
60
52
 
61
- \*Operations per second on an AMD Ryzen 5 5600x
53
+ Sources: [classix](https://bundlephobia.com/package/classix), [clsx](https://bundlephobia.com/package/clsx), [classnames](https://bundlephobia.com/package/classnames)
62
54
 
63
- \*\*classix aims to provide the fastest and tiniest utility by omitting the object API, which it considers less ergonomic than standard function arguments:
55
+ ![Performance comparison chart](media/perf.png)
56
+
57
+ Sources: Ran [benchmark](benchmark/) on an AMD Ryzen 5 5600x.
58
+
59
+ Compared to other librairies, classix simplifies its API by forbidding object arguments, which it considers less ergonomic than string expressions:
64
60
 
65
61
  ```js
66
62
  // 🚫
67
- cx({ class1: isPrimary && isLarge, class2: !isPrimary || !isLarge });
63
+ cx({ "class-1": isPrimary && isLarge, "class-2": !isPrimary || !isLarge });
68
64
  // ✅
69
- cx(isPrimary && isLarge ? "class1" : "class2");
65
+ cx(isPrimary && isLarge ? "class-1" : "class-2");
70
66
  ```
71
67
 
72
68
  ## Highlights
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare type Argument = string | boolean | number | null | undefined;
1
+ declare type Argument = string | boolean | null | undefined;
2
2
  /**
3
3
  * Conditionally join classNames into a single string
4
4
  * @param {...String} args The expressions to evaluate
package/dist/index.js CHANGED
@@ -4,8 +4,7 @@ exports.cx = void 0;
4
4
  function cx() {
5
5
  var str = "", i = 0, arg;
6
6
  while (i < arguments.length) {
7
- if ((arg = arguments[i++]) &&
8
- (typeof arg === "string" || typeof arg === "number")) {
7
+ if ((arg = arguments[i++]) && typeof arg === "string") {
9
8
  str && (str += " ");
10
9
  str += arg;
11
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "classix",
3
- "version": "1.2.1",
3
+ "version": "2.0.1",
4
4
  "description": "The fastest and tiniest utility for conditionally joining classNames.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",