@insanedev2478/tstoolset 1.3.0 → 1.4.0

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
@@ -1,9 +1,9 @@
1
- # 🧰 **tstoolset**
1
+ # 🧰 **tstoolset**
2
+
2
3
  **Open-source**, **Zero‑runtime** TypeScript **utility types** for cleaner, safer, more expressive code. <br>
3
4
  ![npm version](https://img.shields.io/npm/v/@insanedev2478/tstoolset)
4
5
  ![license](https://img.shields.io/github/license/vedanshshetti/tstoolset)
5
6
 
6
-
7
7
  ---
8
8
 
9
9
  ## 🚀 Installation
@@ -23,12 +23,15 @@ npm install @insanedev2478/tstoolset
23
23
  - Exact object enforcement with `Exact<T>`
24
24
  - Safe assertion helper: `convert<T>(x)`
25
25
  - Zero runtime cost — pure TypeScript
26
+ - Object schema merger with `Merge<A, B>`
27
+ - snake_case to camelCase conversion with `CamelCase<string>`
26
28
 
27
29
  ---
28
30
 
29
31
  ## 📦 Usage
30
32
 
31
33
  ### **Primitive & container helpers**
34
+
32
35
  ```ts
33
36
  import type { String, Obj, Arr } from "@insanedev2478/tstoolset";
34
37
 
@@ -37,24 +40,40 @@ type Tags = Arr<String>;
37
40
  ```
38
41
 
39
42
  ### **Exact object enforcement**
43
+
40
44
  ```ts
41
45
  import type { Exact } from "@insanedev2478/tstoolset";
42
46
 
43
47
  type User = { id: string };
44
- const u: Exact<User> = { id: "123" }; // ok
45
- const x: Exact<User> = { id: "123", a: 1 } // ❌ extra key
48
+ const u: Exact<User> = { id: "123" }; // ok
49
+ const x: Exact<User> = { id: "123", a: 1 }; // ❌ extra key
46
50
  ```
47
51
 
48
- ### **snake_case to camelCase**
52
+ ### snake_case to camelCase 🔁
53
+
49
54
  ```ts
50
55
  import type { CamelCase } from "@insanedev2478/tstoolset";
56
+ import { convertToCamelCase } from "@insanedev2478/tstoolset";
51
57
 
52
- type User = { id: string };
53
- const u: Exact<User> = { id: "123" }; // ok
54
- const x: Exact<User> = { id: "123", a: 1 } // ❌ extra key
58
+ // Type-level examples:
59
+ type A = CamelCase<"snake_case">; // 'snakeCase'
60
+ type B = CamelCase<"multi_part_name">; // 'multiPartName'
61
+ type C = CamelCase<"alreadyCamel">; // 'alreadyCamel'
62
+
63
+ // Using a literal (type-level):
64
+ const s = "hello_world" as const;
65
+ type S = CamelCase<typeof s>; // 'helloWorld'
66
+
67
+ // Runtime helper `convertToCamelCase` preserves the typed relationship when used with literal types
68
+ const r = convertToCamelCase(s); // 'helloWorld' (type: CamelCase<typeof s>)
69
+
70
+ // It also handles dashes and spaces, and collapses multiple separators:
71
+ const r2 = convertToCamelCase("multi-part name" as const); // 'multiPartName'
72
+ const r3 = convertToCamelCase("alreadyCamel" as const); // 'alreadyCamel'
55
73
  ```
56
74
 
57
75
  ### **Nominal typing**
76
+
58
77
  ```ts
59
78
  import type { Brand } from "@insanedev2478/tstoolset";
60
79
 
@@ -64,20 +83,21 @@ const id: UserId = "abc" as UserId;
64
83
  ```
65
84
 
66
85
  ### **Merge**
86
+
67
87
  ```ts
68
88
  import type { Merge } from "@insanedev2478/tstoolset";
69
89
  type A = { id: string; name: string };
70
90
  type B = { id: number; admin: boolean };
71
91
 
72
92
  const merged: Merge<A, B> = {
73
- id: 123, // overridden by B
93
+ id: 123, // overridden by B
74
94
  name: "John",
75
- admin: true
95
+ admin: true,
76
96
  };
77
-
78
97
  ```
79
98
 
80
99
  ### **UUID & Email template types**
100
+
81
101
  ```ts
82
102
  import type { UUIDV4, TrustableEmail } from "@insanedev2478/tstoolset";
83
103
 
@@ -86,6 +106,7 @@ const email: TrustableEmail = "user@gmail.com";
86
106
  ```
87
107
 
88
108
  ### **Safe converter**
109
+
89
110
  ```ts
90
111
  import { convert } from "@insanedev2478/tstoolset";
91
112
 
@@ -98,13 +119,14 @@ const fn = convert<(...args: any[]) => void>(() => {});
98
119
 
99
120
  - Deep utilities (`DeepPartial`, `DeepReadonly`, `DeepRequired`)
100
121
  - JSON‑safe types (`JsonValue`, `JsonObject`)
101
- - String manipulation types (`CamelCase`, `KebabCase`)
122
+ - String manipulation types (`KebabCase`, `snake-case`)
102
123
  - Schema‑style helpers
103
124
  - More branded primitives
104
125
 
105
126
  ---
106
127
 
107
128
  ## 🤝 Contributing
129
+
108
130
  I am still a 6th grader, so new releases will only be on weekends, but <br>
109
131
  issues, ideas, and PRs are welcome — this project is growing fast and feedback helps shape the toolkit.
110
132
 
package/dist/index.d.ts CHANGED
@@ -27,9 +27,10 @@ export type Brand<T, Name> = T & {
27
27
  [brand]: Name;
28
28
  };
29
29
  type ConvertableTypes = Primitive | Obj | Arr | Func | TrustableEmail | UUIDV4;
30
- export declare function convert<T extends ConvertableTypes>(x: unknown): T;
31
30
  export type Merge<A, B> = {
32
31
  [K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never;
33
32
  };
34
- export type CamelCase<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${CamelCase<Capitalize<Tail>>}` : S;
33
+ export type CamelCase<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${CamelCase<Capitalize<Tail>>}` : S extends `${infer Head}-${infer Tail}` ? `${Head}${CamelCase<Capitalize<Tail>>}` : S extends `${infer Head} ${infer Tail}` ? `${Head}${CamelCase<Capitalize<Tail>>}` : S;
34
+ export declare function convert<T extends ConvertableTypes>(x: unknown): T;
35
+ export declare function convertToCamelCase<S extends string>(str: S): CamelCase<S>;
35
36
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insanedev2478/tstoolset",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Collection of handy TypeScript types, ranging from primitives like numbers all the way to UUIDs and Email Addresses. ",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,8 +16,7 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "build": "tsc --emitDeclarationOnly --declaration --outDir dist ./src/index.ts",
19
- "prepublishOnly": "npm run build",
20
- "github:commit": "git add . && git commit -m \"Added new script to package.json\""
19
+ "prepublishOnly": "npm run build"
21
20
  },
22
21
  "keywords": [
23
22
  "typescript",