cnfast 0.0.2

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 ADDED
@@ -0,0 +1,34 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aiden Bai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ -------------------------------------------------------------------------------
24
+
25
+ fastcn bundles and adapts code from the following MIT-licensed projects:
26
+
27
+ clsx — Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
28
+ https://github.com/lukeed/clsx
29
+
30
+ tailwind-merge — Copyright (c) 2021 Dany Castillo
31
+ https://github.com/dcastil/tailwind-merge
32
+
33
+ Both are distributed under the MIT License, the full text of which is identical
34
+ to the license above (with their respective copyright holders).
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # cnfast
2
+
3
+ [![version](https://img.shields.io/npm/v/cnfast?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/cnfast)
4
+ [![downloads](https://img.shields.io/npm/dt/cnfast.svg?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/cnfast)
5
+
6
+ A faster, drop-in replacement for the `cn` utility (`clsx` + `tailwind-merge`) with 100% output parity.
7
+
8
+ ```ts
9
+ import { cn } from "cnfast";
10
+
11
+ cn("px-2 py-1", isActive && "px-4", { "text-red-500": hasError });
12
+ // "py-1 px-4 text-red-500"
13
+ ```
14
+
15
+ `cn` joins class values like `clsx` (strings, numbers, arrays, objects) and then resolves
16
+ Tailwind conflicts like `tailwind-merge` — the exact behavior of the common shadcn/ui helper:
17
+
18
+ ```ts
19
+ import { clsx, type ClassValue } from "clsx";
20
+ import { twMerge } from "tailwind-merge";
21
+
22
+ export function cn(...inputs: ClassValue[]) {
23
+ return twMerge(clsx(inputs));
24
+ }
25
+ ```
26
+
27
+ ## Why
28
+
29
+ - 100% output parity with `clsx` + `tailwind-merge` (verified against their test suites and a differential fuzz harness over real-world data).
30
+ - Faster on workloads that reuse class tokens across many distinct combinations, via per-token memoization.
31
+ - Drop-in API: `cn`, `clsx`, `twMerge`, `twJoin`, `createTailwindMerge`, `extendTailwindMerge`, `mergeConfigs`, `fromTheme`, `getDefaultConfig`, `validators`.
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ npm install cnfast
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```ts
42
+ import { cn, twMerge, clsx } from "cnfast";
43
+
44
+ cn("p-2", "p-4"); // "p-4"
45
+ clsx("a", { b: true, c: false }); // "a b"
46
+ twMerge("px-2 px-4"); // "px-4"
47
+ ```
48
+
49
+ ## Development
50
+
51
+ ```bash
52
+ pnpm install
53
+ pnpm build
54
+ pnpm test # parity + behavioral suites
55
+ pnpm --filter cnfast bench # speed vs clsx + tailwind-merge
56
+ pnpm --filter cnfast size # gzipped bundle comparison
57
+ ```
58
+
59
+ ## Credits
60
+
61
+ cnfast adapts MIT-licensed code from [clsx](https://github.com/lukeed/clsx) (Luke Edwards)
62
+ and [tailwind-merge](https://github.com/dcastil/tailwind-merge) (Dany Castillo). See [LICENSE](../../LICENSE).
63
+
64
+ ## License
65
+
66
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import module from "node:module";
3
+
4
+ if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
5
+ try {
6
+ module.enableCompileCache();
7
+ } catch {
8
+ // Ignore compile-cache errors.
9
+ }
10
+ }
11
+
12
+ await import("../dist/cli.js");
@@ -0,0 +1,18 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (!no_symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __exportAll as t };