@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 +1 -2
- package/README.md +21 -18
- package/dist/index.js +1 -1
- package/package.json +10 -3
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
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
|
[](https://www.npmjs.com/package/@lightsound/cn)
|
|
6
|
-
[](https://github.com/lightsound/cn/actions/workflows/ci.yml)
|
|
7
|
+
[](https://bundlephobia.com/package/@lightsound/cn)
|
|
7
8
|
[](./LICENSE)
|
|
8
9
|
|
|
9
10
|
## Features
|
|
10
11
|
|
|
11
|
-
- **Blazing Fast**: Up to
|
|
12
|
-
- **Tiny**: ~
|
|
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
|
-
|
|
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
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
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
|
|
125
|
-
| --------------- | -------------- |
|
|
126
|
-
| Strings only | ✅ | ❌ |
|
|
127
|
-
| Objects support | ❌ | ✅ |
|
|
128
|
-
| Arrays support | ❌ | ✅ |
|
|
129
|
-
| Size (gzip) | ~
|
|
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
|
|
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(){
|
|
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": "
|
|
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
|
-
"
|
|
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": "
|
|
57
|
+
"clsx": "*",
|
|
58
|
+
"husky": "^9.1.7",
|
|
52
59
|
"mitata": "^1.0.34"
|
|
53
60
|
}
|
|
54
61
|
}
|