@lightsound/cn 0.1.0 → 1.0.3

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 lightsound
3
+ Copyright (c) 2025 lightsound
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
-
package/README.md CHANGED
@@ -3,27 +3,30 @@
3
3
  A tiny, **blazing fast** utility for constructing `className` strings conditionally.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@lightsound/cn.svg)](https://www.npmjs.com/package/@lightsound/cn)
6
- [![gzip size](https://img.shields.io/badge/gzip-139B-brightgreen.svg)](https://bundlephobia.com/package/@lightsound/cn)
6
+ [![CI](https://github.com/lightsound/cn/actions/workflows/ci.yml/badge.svg)](https://github.com/lightsound/cn/actions/workflows/ci.yml)
7
+ [![gzip size](https://img.shields.io/badge/gzip-130B-brightgreen.svg)](https://bundlephobia.com/package/@lightsound/cn)
7
8
  [![license](https://img.shields.io/npm/l/@lightsound/cn.svg)](./LICENSE)
8
9
 
9
10
  ## Features
10
11
 
11
- - **Blazing Fast**: Up to 48% faster than `clsx/lite`
12
- - **Tiny**: ~139B gzipped (smaller than clsx/lite!)
12
+ - **Blazing Fast**: Up to 22% faster than `clsx/lite`
13
+ - **Tiny**: ~130B gzipped (smaller than clsx/lite!)
13
14
  - **TypeScript**: Full type support out of the box
14
15
  - **Simple API**: Strings only - no objects, no arrays, maximum performance
15
16
  - **Zero Dependencies**: No external dependencies
16
17
 
17
18
  ## Benchmarks
18
19
 
19
- Benchmarked on Apple M2 with Bun 1.3.4:
20
+ > Benchmarks are run on every CI build. See the [latest CI run](https://github.com/lightsound/cn/actions/workflows/ci.yml) for up-to-date results.
20
21
 
21
- | Test Case | @lightsound/cn | clsx/lite | Improvement |
22
- | ---------- | -------------- | --------- | -------------- |
23
- | 2 strings | 21.17 ns | 33.23 ns | **36% faster** |
24
- | 3 strings | 25.74 ns | 46.05 ns | **44% faster** |
25
- | 5 strings | 37.84 ns | 70.59 ns | **46% faster** |
26
- | 10 strings | 63.60 ns | 121.75 ns | **48% faster** |
22
+ <!-- BENCHMARK_START -->
23
+ | Test Case | @lightsound/cn | clsx/lite | Improvement |
24
+ | --------- | -------------- | --------- | ----------- |
25
+ | 2 strings | 78.04 ns | 83.64 ns | **7% faster** |
26
+ | 3 strings | 71.58 ns | 90.05 ns | **21% faster** |
27
+ | 5 strings | 83.23 ns | 107.13 ns | **22% faster** |
28
+ | 10 strings | 142.39 ns | 164.93 ns | **14% faster** |
29
+ <!-- BENCHMARK_END -->
27
30
 
28
31
  ## Installation
29
32
 
@@ -121,19 +124,19 @@ Combines class names into a single string. Only accepts strings - non-string val
121
124
 
122
125
  ## Why @lightsound/cn?
123
126
 
124
- | Feature | @lightsound/cn | clsx | clsx/lite |
125
- | --------------- | -------------- | ----- | --------- |
126
- | Strings only | ✅ | ❌ | ✅ |
127
- | Objects support | ❌ | ✅ | ❌ |
128
- | Arrays support | ❌ | ✅ | ❌ |
129
- | Size (gzip) | ~139B | ~239B | ~149B |
130
- | Performance | ⚡⚡⚡ | ⚡⚡ | ⚡⚡ |
127
+ | Feature | @lightsound/cn | clsx/lite | clsx |
128
+ | --------------- | -------------- | --------- | ----- |
129
+ | Strings only | ✅ | ✅ | ❌ |
130
+ | Objects support | ❌ | ❌ | ✅ |
131
+ | Arrays support | ❌ | ❌ | ✅ |
132
+ | Size (gzip) | ~130B | ~139B | ~239B |
133
+ | Performance | ⚡⚡⚡ | ⚡⚡ | |
131
134
 
132
135
  If you only use string-based class composition (the most common pattern with Tailwind CSS), `@lightsound/cn` provides the best performance.
133
136
 
134
137
  ## Compatibility with clsx/lite
135
138
 
136
- `@lightsound/cn` is designed as a faster, drop-in replacement for `clsx/lite` in typical usage:
139
+ `@lightsound/cn` is designed as a faster, drop-in replacement for `clsx/lite`:
137
140
 
138
141
  ```typescript
139
142
  // Before
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- function e(){let s="",a,l=arguments.length;for(let n=0;n<l;n++)if(a=arguments[n])s=s?s+" "+a:a;return s}export{e as default,e as cn};
1
+ function e(){var a=0,l=arguments.length,s="",n;for(;a<l;a++)if(n=arguments[a])s=s?s+" "+n:n;return s}export{e as default,e as cn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsound/cn",
3
- "version": "0.1.0",
3
+ "version": "1.0.3",
4
4
  "description": "A tiny, blazing fast utility for constructing className strings conditionally",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,11 @@
23
23
  "test": "bun test",
24
24
  "test:watch": "bun test --watch",
25
25
  "bench": "bun run bench/index.ts",
26
- "prepublishOnly": "bun run build && bun run test"
26
+ "bench:ci": "bun run bench/ci.ts",
27
+ "check-size": "bun run scripts/check-size.ts",
28
+ "update-readme": "bun run scripts/update-readme.ts",
29
+ "prepublishOnly": "bun run build && bun run test",
30
+ "prepare": "husky"
27
31
  },
28
32
  "keywords": [
29
33
  "classnames",
@@ -46,9 +50,12 @@
46
50
  },
47
51
  "homepage": "https://github.com/lightsound/cn#readme",
48
52
  "devDependencies": {
53
+ "@commitlint/cli": "^20.2.0",
54
+ "@commitlint/config-conventional": "^20.2.0",
49
55
  "@types/bun": "^1.3.4",
50
56
  "@typescript/native-preview": "^7.0.0-dev.20251213.1",
51
- "clsx": "^2.1.1",
57
+ "clsx": "*",
58
+ "husky": "^9.1.7",
52
59
  "mitata": "^1.0.34"
53
60
  }
54
61
  }