@avstantso/ts 1.3.1 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.3] - 2026-01-15
4
+
5
+ ### Fixed
6
+
7
+ - Fixed AI hallucinations in README.md
8
+
9
+ ## [1.3.2] - 2026-02-05
10
+
11
+ ### Changed
12
+
13
+ - +String.Split
14
+
3
15
 
4
16
  ## [1.3.1] - 2026-02-04
5
17
 
package/README.md CHANGED
@@ -73,22 +73,189 @@ const flattened = TS.flat({ a: 1, b: { c: 2 } }); // { a: 1, c: 2 }
73
73
 
74
74
  The `@avstantso/ts` package provides a comprehensive suite of type-level utilities organized into the following namespaces:
75
75
 
76
- - [TS.Extends](#tsextends) - Type extension checking
77
- - [TS.Increment / TS.Decrement](#tsincrement--tsdecrement) - Numeric type arithmetic
78
- - [TS.Func](#tsfunc) - Function type utilities
79
- - [TS.Union](#tsunion) - Union type manipulation
80
- - [TS.Array](#tsarray) - Array type utilities
81
- - [TS.ASCII](#tsascii) - ASCII character types and maps
82
- - [TS.Comparisons](#tscomparisons) - Type-level comparisons
83
- - [TS.String](#tsstring) - String type manipulation
84
- - [TS.Structure](#tsstructure) - Object structure utilities
85
- - [Object Constructor Extensions](#object-constructor-extensions) - Typed Object.keys/values/entries
86
- - [TS.Boolean](#tsboolean) - Boolean logic types
87
- - [TS.Numeric](#tsnumeric) - Numeric literal utilities
88
- - [TS.Literal](#tsliteral) - Type literal definitions
89
- - [TS.Type](#tstype) - Type manipulation utilities
90
- - [TS.Resolve](#tsresolve) - Type literal resolution
91
- - [TS Utility Types](#ts-utility-types) - Miscellaneous utility types
76
+ - [TS.Extends](#tsextends) Type extension checking
77
+ - [TS.Increment / TS.Decrement](#tsincrement--tsdecrement) Numeric type arithmetic
78
+ - [TS.ArrN / TS.ArrM](#tsarrn-and-tsarrm) Array type constraints
79
+ - [TS.Func](#tsfunc) Function type utilities
80
+ - [TS.Func.Nested](#tsfuncnesteddepth-r-p) Nested function type
81
+ - [TS.Union](#tsunion) Union type manipulation
82
+ - [TS.Union.ToIntersection](#tsuniontointersectionu) Union → intersection
83
+ - [TS.Union.Pop](#tsunionpopu) Pop last from union
84
+ - [TS.Union.ToTuple](#tsuniontotupleu) Union tuple
85
+ - [TS.IsUnion](#tsisuniont-iftrue--true-iffalse--false) Test if union
86
+ - [TS.Array](#tsarray) Array type utilities
87
+ - Creation
88
+ - [TS.Array.Create](#tsarraycreatel-item) Create array of length
89
+ - [TS.Array.Create.Optional](#tsarraycreateoptionald-item) Create optional array
90
+ - [TS.Array.Numbers](#tsarraynumbersl) Numeric literals array
91
+ - [TS.Array.Letters](#tsarraylettersl) Letters array
92
+ - Analysis
93
+ - [TS.Array.Length](#tsarraylength-tarr) — Array length
94
+ - [TS.Array.Length.IfExeeded](#tsarraylengthifexeededtarr-n-iftrue--true-iffalse--false) — Test length exceeded
95
+ - Search
96
+ - [TS.Array.IndexOf](#tsarrayindexoftarr-item-i--0) — Find index of item
97
+ - [TS.Array.IfHasItem](#tsarrayifhasitemtarr-item-iftrue--true-iffalse--false) — Test has item
98
+ - [TS.Array.IfEach](#tsarrayifeachtarr-item-iftrue--true-iffalse--false) — Test each item
99
+ - [TS.Array.CountOf](#tsarraycountoftarr-item) — Count matching items
100
+ - Transformation
101
+ - [TS.Array.AddUnique](#tsarrayadduniquetarr-item) — Add unique item
102
+ - [TS.Array.MergeUnique](#tsarraymergeuniquetarr1-tarr2) — Merge without duplicates
103
+ - [TS.Array.Filter](#tsarrayfiltertarr-tfilter--undefined) — Filter items
104
+ - [TS.Array.Filter.Unique](#tsarrayfilteruniquetarr) — Remove duplicates
105
+ - [TS.Array.Sub](#tsarraysubtarr-start-end) — Sub-array
106
+ - [TS.Array.Remove](#tsarrayremovetarr-start-end) — Remove section
107
+ - [TS.Array.Reverse](#tsarrayreversetarr) — Reverse array
108
+ - [TS.Array.Join](#tsarrayjointarr) — Join to string
109
+ - [TS.Array.Cast](#tsarraycasttarr-item--any) — Cast items to type
110
+ - Map / Record
111
+ - [TS.Array.ToKey](#tsarraytokeytarr) — Array → key union
112
+ - [TS.Array.ToKey2Key](#tsarraytokey2keytarr) — Key-to-key record
113
+ - [TS.Array.ToRecord](#tsarraytorecordtarr-t) — Array → record
114
+ - [TS.Array.KeyValueMapFrom](#tsarraykeyvaluemapfromkeys-firstvalue--0) — Key-value map
115
+ - [TS.Array.ValueKeyMapFrom](#tsarrayvaluekeymapfromkeys-firstvalue--0) — Value-key map
116
+ - Min / Max / Sort
117
+ - [TS.Array.Min](#tsarraymintarr) — Find minimum
118
+ - [TS.Array.Min.Index](#tsarrayminindextarr) — Find minimum index
119
+ - [TS.Array.Max](#tsarraymaxtarr) — Find maximum
120
+ - [TS.Array.Max.Index](#tsarraymaxindextarr) — Find maximum index
121
+ - [TS.Array.Sort](#tsarraysorttarr-asc--true) — Sort array
122
+ - [TS.Array.Sort.Pair](#tsarraysortpairk) — Pair for key-based sorting
123
+ - [TS.Array.Sort.Desc](#tsarraysortdesctarr) — Sort descending
124
+ - Runtime
125
+ - [TS.Array.ToKey2Key()](#tsarraytokey2keyaarr-a) — Create key-to-key record (runtime)
126
+ - [TS.ASCII](#tsascii) — ASCII character types and maps
127
+ - Letters
128
+ - [TS.ASCII.Letters](#tsasciilettersisuppertrue) — Letter array by case
129
+ - [TS.ASCII.Letters.Upper](#tsasciilettersupper) / [.Lower](#tsasciiletterslower) — Upper/lowercase letter arrays
130
+ - [TS.ASCII.Letter](#tsasciiletter) — Letter union by case
131
+ - [TS.ASCII.Letter.Upper](#tsasciiletterupper) / [.Lower](#tsasciiletterlower) — Upper/lowercase letter unions
132
+ - Character Arrays
133
+ - [TS.ASCII](#tsascii-2) — All ASCII characters
134
+ - [TS.ASCII.Control](#tsasciicontrol) / [.Printable](#tsasciiprintable) / [.Extended](#tsasciiextended) — Character subsets
135
+ - Maps
136
+ - [TS.ASCII.Map](#tsasciimap) — Character → code map
137
+ - [TS.ASCII.Map.Control](#tsasciimapcontrol) / [.Printable](#tsasciimapprintable) / [.Extended](#tsasciimapextended) — Subset maps
138
+ - [TS.ASCII.Code](#tsasciicode) — Character → code lookup
139
+ - [TS.ASCII.Character](#tsasciicharacter) — All ASCII characters union
140
+ - **Type-level comparisons**
141
+ - [TS.LT](#tslt) — Less than
142
+ - [TS.LTE](#tslte) — Less than or equal
143
+ - [TS.GT](#tsgt) — Greater than
144
+ - [TS.GTE](#tsgte) — Greater than or equal
145
+ - [TS.String](#tsstring) — String type manipulation
146
+ - [TS.String\<T, D\>](#tsstring-1) — Cast to string literal
147
+ - [TS.String.Possible](#tsstringpossible) — Convertible types
148
+ - [TS.String.Pattern](#tsstringpattern) — Regex pattern shortcuts
149
+ - Analysis
150
+ - [TS.String.Length](#tsstringlength) — String length
151
+ - [TS.String.IsLengthBetween](#tsstringislengthbetween) — Length in range
152
+ - [TS.String.SplitToChars](#tsstringsplittochars) — Split to characters
153
+ - [TS.String.Split](#tsstringsplits-separator) — Split by separator
154
+ - Manipulation
155
+ - [TS.String.Repeat](#tsstringrepeat) — Repeat N times
156
+ - [TS.String.Includes](#tsstringincludes) — Test includes pattern
157
+ - [TS.String.IndexOf](#tsstringindexof) — Find pattern index
158
+ - [TS.String.Replace](#tsstringreplace) — Replace matches
159
+ - [TS.String.Trim](#tsstringtrim) — Trim whitespace
160
+ - [TS.String.Trim.Start](#tsstringtrimstart) / [.End](#tsstringtrimend) — Trim start/end
161
+ - Case Conversion
162
+ - [TS.String.Case](#tsstringcasetype-s-r) — Generic case conversion
163
+ - [TS.String.Case.Camel](#tsstringcasecamels-r--removes) — camelCase
164
+ - [TS.String.Case.Pascal](#tsstringcasepascals-r--removes) — PascalCase
165
+ - [TS.String.Case.Snake](#tsstringcasesnakes-r--removes) — snake_case
166
+ - [TS.String.Case.Snake.Up](#tsstringcasesnakeups-r--removes) — UPPER_SNAKE_CASE
167
+ - [TS.String.Case.Kebab](#tsstringcasekebabs-r--removes) — kebab-case
168
+ - [TS.String.Case.Settings.Removes](#tsstringcasesettingsremoves) — Removal characters
169
+ - [TS.String.Case.Settings.Removes.Map](#tsstringcasesettingsremovesmap) — Extensible removal map
170
+ - [TS.Structure](#tsstructure) — Object structure utilities
171
+ - Test
172
+ - [TS.Structure.IfStructure](#tsstructureifstructuret-iftrue--true-iffalse--false) — Test is structure
173
+ - [TS.Structure](#tsstructuret) — Structure constraint
174
+ - [TS.Structure.Wildcard](#tsstructurewildcard) / [.MapOfNotRules](#tsstructuremapofnotrules) / [.NotRules](#tsstructurenotrules) — Rules
175
+ - Conversion
176
+ - [TS.Structure.ToKeysArray](#tsstructuretokenysarrayo) — Keys tuple
177
+ - [TS.Structure.ToValuesArray](#tsstructuretovaluesarrayo) — Values tuple
178
+ - [TS.Structure.ToEntriesArray](#tsstructuretoentriesarrayo) — Entries tuple
179
+ - Manipulation
180
+ - [TS.Structure.Separate](#tsstructureseparatet) — Separate plain/structural
181
+ - [TS.Structure.Reverse](#tsstructurereverse) — Reverse to value-key map
182
+ - [TS.Structure.Split](#tsstructuresplito) — Split to single-field objects
183
+ - [TS.Structure.Combine](#tsstructurecombinea) — Combine objects
184
+ - Runtime
185
+ - [TS.Structure.is()](#tsstructureis) — Test is structure (runtime)
186
+ - [TS.Structure.keyByValue()](#tsstructurekeybyvalue) — Find key by value (runtime)
187
+ - [TS.Structure.reverse()](#tsstructurereverse-1) — Reverse structure (runtime)
188
+ - [Object Constructor Extensions](#object-constructor-extensions) — Typed Object.keys/values/entries
189
+ - [Object.keysEx](#objectkeyso)
190
+ - [Object.valuesEx](#objectvaluesexo)
191
+ - [Object.entriesEx](#objectentriesexo)
192
+ - **Boolean logic types**
193
+ - [TS.If](#tsifcondition-iftrue--true-iffalse--false) — Conditional
194
+ - [TS.And](#tsandconditions-iftrue--true-iffalse--false) — Logical AND
195
+ - [TS.Or](#tsorconditions-iftrue--true-iffalse--false) — Logical OR
196
+ - [TS.Xor](#tsxorconditions-iftrue--true-iffalse--false) — Logical XOR
197
+ - [TS.Numeric](#tsnumeric) — Numeric literal utilities
198
+ - Domain-Independent
199
+ - [TS.Numeric.IsPositive](#tsnumericispositive) / [.IsNegative](#tsnumericisnegative) — Sign tests
200
+ - [TS.Numeric.Positive.ToNegative](#tsnumericpositivetonegative) / [Numeric.Negative.ToPositive](#tsnumericnegativetopositive) — Sign conversion
201
+ - [TS.Numeric.Sign](#tsnumericsign) — Get sign
202
+ - [TS.Numeric.Digits](#tsnumericdigits) — Digit characters
203
+ - [TS.Numeric.Digits.Map](#tsnumericdigitsmap) / [.IsOdd](#tsnumericdigitsisodd) — Digit maps
204
+ - [TS.Numeric.Digits.Hex](#tsnumericdigitshex) / [.Hex.Map](#tsnumericdigitshexmap) — Hexadecimal digits
205
+ - [TS.Numeric.IsOdd](#tsnumericisodd) / [.IsEven](#tsnumericiseven) — Parity tests
206
+ - [TS.Numeric.IsNumber](#tsnumericisnumber) — String → number test
207
+ - [TS.Numeric.Parse](#tsnumericparse) — String → number literal
208
+ - Domain
209
+ - [TS.Numeric.Domain.Positive](#tsnumericdomainpositive) / [.Negative](#tsnumericdomainnegative) — Numeric ranges
210
+ - [TS.Numeric.Domain.Increment](#tsnumericdomainincrement) / [.Decrement](#tsnumericdomaindecrement) — Full-domain inc/dec
211
+ - Math
212
+ - [TS.Numeric.Abs](#tsnumericabsn) — Absolute value
213
+ - [TS.Numeric.Invert](#tsnumericinvertn) — Invert sign
214
+ - [TS.Numeric.Summ](#tsnumericsummx-y) — Addition
215
+ - [TS.Numeric.Diff](#tsnumericdiffx-y) — Subtraction
216
+ - [TS.Numeric.Multiply](#tsnumericmultiplyx-y) — Multiplication
217
+ - [TS.Numeric.Div](#tsnumericdivx-y) — Division
218
+ - [TS.Numeric.Power](#tsnumericpowerx-e) — Exponentiation
219
+ - [TS.Literal](#tsliteral) — Type literal definitions
220
+ - [TS.Literal](#tsliteral-1) — Available literals union
221
+ - [TS.Literal.Map](#tsliteralmap) — Literal → type map
222
+ - [TS.Literal.NumberLike](#tsliteralnumberlike) / [.IsNumberLike](#tsliteralisnumberlike) — Number-like literals
223
+ - [TS.Literal.StringLike](#tsliteralstringlike) / [.IsStringLike](#tsliteralisstringlike) — String-like literals
224
+ - [TS.Literal.List](#tsliterallist) — Literals array
225
+ - [TS.Literal.Key2KeyRec](#tsliteralkey2keyrec) — Key-to-key record
226
+ - Runtime
227
+ - [TS.Literal.List](#tsliterallist-1) — Literals array (runtime)
228
+ - [TS.Literal.Empty()](#tsliteralemptytype) — Get empty value
229
+ - [TS.Literal.IsValue()](#tsliteralisvaluetype-value) — Type guard
230
+ - [TS.Literal._Register()](#tsliteral_registerliteral-empty) — Register custom literal
231
+ - [TS.Type](#tstype) — Type manipulation utilities
232
+ - [TS.Type](#tstype-1) — Available types union
233
+ - [TS.Type.Not](#tstypenotfunction) — Exclude types
234
+ - [TS.Type.Def](#tstypedef) — Type definition structure
235
+ - [TS.Type.KeyDef](#tstypekeydef) — Keyed type definition
236
+ - [TS.Type.KLD](#tstypekld) — Key-literal-default array
237
+ - [TS.Type.Union](#tstypeunion) — Type union with literal
238
+ - Runtime
239
+ - [TS.Type.KeyDef()](#tstypekeydefkey-type) — Create keyed def (runtime)
240
+ - [TS.Type.KLD()](#tstypekldkey-type-def) — Create KLD (runtime)
241
+ - [TS.Resolve](#tsresolve) — Type literal resolution
242
+ - **Utility Types** — Miscellaneous utility types
243
+ - [TS.Alt](#tsaltt) — Alternative fields
244
+ - [TS.Flat](#tsflatt-depth--1) — Flatten structure
245
+ - [TS.IfDef](#tsifdef) / [TS.IfDefKey](#tsifdefkey) — Defined selection
246
+ - [TS.Opaque](#tsopaquetypemeta-t) — Opaque/nominal types
247
+ - [TS.Options](#tsoptionstypemap-tdefaults) — Options with defaults
248
+ - Override
249
+ - [TS.Override](#tsoverridetbase-textended-toptional--false) — Override properties
250
+ - [TS.IfIsOverrided](#tsifisoverrided) / [.IfIsOverridedKey](#tsifisoverridedkey) — Test overridden
251
+ - [TS.IfNotOverrided](#tsifnotoverrided) / [.IfNotOverridedKey](#tsifnotoverridedkey) — Select if not overridden
252
+ - [TS.OverrideIfNot](#tsoverrideifnot) — Conditional override
253
+ - [TS.ReplaceKey](#tsreplacekey) / [TS.ReplaceKeyOpt](#tsreplacekeyopt) — Replace key type
254
+ - [TS.RequiredKeys](#tsrequiredkeys) / [TS.OptionalKeys](#tsoptionalkeys) — Key extraction
255
+ - [TS.Merge](#tsmerge) / [TS.Merge.Fields](#tsmergefields) — Type merging
256
+ - Runtime
257
+ - [TS.isKey()](#tsiskeyk-extends-avstandsotskey) — Key type guard
258
+ - [TS.flat()](#tsflatstructure-depth--1) — Flatten structure (runtime)
92
259
 
93
260
  ---
94
261
 
@@ -252,7 +419,7 @@ type Union = 'a' | 'b' | 'c';
252
419
  type Tuple = TS.Union.ToTuple<Union>; // ['a', 'b', 'c'] (order may vary)
253
420
  ```
254
421
 
255
- ### `TS.Union.IsUnion<T, IfTrue = true, IfFalse = false>`
422
+ ### `TS.IsUnion<T, IfTrue = true, IfFalse = false>`
256
423
 
257
424
  Test if type is a union.
258
425
 
@@ -263,10 +430,10 @@ import { TS } from '@avstantso/ts';
263
430
  type MyUnion = 'a' | 'b' | 'c';
264
431
  type NotUnion = string;
265
432
 
266
- type Check1 = TS.Union.IsUnion<MyUnion>; // true
267
- type Check2 = TS.Union.IsUnion<NotUnion>; // false
268
- type Check3 = TS.Union.IsUnion<never>; // false
269
- type Check4 = TS.Union.IsUnion<number | boolean>; // true
433
+ type Check1 = TS.IsUnion<MyUnion>; // true
434
+ type Check2 = TS.IsUnion<NotUnion>; // false
435
+ type Check3 = TS.IsUnion<never>; // false
436
+ type Check4 = TS.IsUnion<number | boolean>; // true
270
437
  ```
271
438
 
272
439
  ---
@@ -637,7 +804,7 @@ type Idx2 = TS.Array.Max.Index<[1, undefined, 2]>; // 2
637
804
 
638
805
  #### `TS.Array.Sort<TArr, Asc = true>`
639
806
 
640
- Sort array items. Allows sorting array of `Sort.Pair<K>` to sort any data by key. Based on [TS.Comparisons](#tscomparisons).
807
+ Sort array items. Allows sorting array of `Sort.Pair<K>` to sort any data by key. Based on [type-level comparisons](#type-level-comparisons).
641
808
 
642
809
  **Example:**
643
810
  ```typescript
@@ -700,7 +867,7 @@ if (Field.version === field) {
700
867
 
701
868
  ## TS.ASCII
702
869
 
703
- ASCII character types and utilities based on [ascii-code.com](https://www.ascii-code.com/). Used in [TS.Comparisons](#tscomparisons) for string comparison operations.
870
+ ASCII character types and utilities based on [ascii-code.com](https://www.ascii-code.com/). Used in [type-level comparisons](#type-level-comparisons) for string comparison operations.
704
871
 
705
872
  ### ASCII Types
706
873
 
@@ -809,15 +976,13 @@ console.log(TS.ASCII.length); // 256
809
976
 
810
977
  ---
811
978
 
812
- ## TS.Comparisons
979
+ ## Type-level Comparisons
813
980
 
814
981
  Type-level number and string comparisons.
815
982
 
816
983
  String comparison is based on [TS.ASCII](#tsascii) character-to-number conversion. Number comparison splits numbers into digit arrays, compares lengths, then iterates through digits from most to least significant.
817
984
 
818
- ### Comparison Types
819
-
820
- #### `TS.Comparisons.LT<A, B, IfTrue = true, IfFalse = false>`
985
+ ### `TS.LT<A, B, IfTrue = true, IfFalse = false>`
821
986
 
822
987
  Test if `A < B`.
823
988
 
@@ -825,12 +990,12 @@ Test if `A < B`.
825
990
  ```typescript
826
991
  import { TS } from '@avstantso/ts';
827
992
 
828
- type NumLess = TS.Comparisons.LT<1, 2>; // true
829
- type NumNotLess = TS.Comparisons.LT<2, 1>; // false
830
- type StrLess = TS.Comparisons.LT<'a', 'b'>; // true
993
+ type NumLess = TS.LT<1, 2>; // true
994
+ type NumNotLess = TS.LT<2, 1>; // false
995
+ type StrLess = TS.LT<'a', 'b'>; // true
831
996
  ```
832
997
 
833
- #### `TS.Comparisons.LTE<A, B, IfTrue = true, IfFalse = false>`
998
+ ### `TS.LTE<A, B, IfTrue = true, IfFalse = false>`
834
999
 
835
1000
  Test if `A <= B`.
836
1001
 
@@ -838,11 +1003,11 @@ Test if `A <= B`.
838
1003
  ```typescript
839
1004
  import { TS } from '@avstantso/ts';
840
1005
 
841
- type NumLessEq = TS.Comparisons.LTE<1, 1>; // true
842
- type StrLessEq = TS.Comparisons.LTE<'a', 'a'>; // true
1006
+ type NumLessEq = TS.LTE<1, 1>; // true
1007
+ type StrLessEq = TS.LTE<'a', 'a'>; // true
843
1008
  ```
844
1009
 
845
- #### `TS.Comparisons.GT<A, B, IfTrue = true, IfFalse = false>`
1010
+ ### `TS.GT<A, B, IfTrue = true, IfFalse = false>`
846
1011
 
847
1012
  Test if `A > B`.
848
1013
 
@@ -850,11 +1015,11 @@ Test if `A > B`.
850
1015
  ```typescript
851
1016
  import { TS } from '@avstantso/ts';
852
1017
 
853
- type NumGreater = TS.Comparisons.GT<2, 1>; // true
854
- type StrGreater = TS.Comparisons.GT<'b', 'a'>; // true
1018
+ type NumGreater = TS.GT<2, 1>; // true
1019
+ type StrGreater = TS.GT<'b', 'a'>; // true
855
1020
  ```
856
1021
 
857
- #### `TS.Comparisons.GTE<A, B, IfTrue = true, IfFalse = false>`
1022
+ ### `TS.GTE<A, B, IfTrue = true, IfFalse = false>`
858
1023
 
859
1024
  Test if `A >= B`.
860
1025
 
@@ -862,8 +1027,8 @@ Test if `A >= B`.
862
1027
  ```typescript
863
1028
  import { TS } from '@avstantso/ts';
864
1029
 
865
- type NumGreaterEq = TS.Comparisons.GTE<2, 2>; // true
866
- type StrGreaterEq = TS.Comparisons.GTE<'b', 'b'>; // true
1030
+ type NumGreaterEq = TS.GTE<2, 2>; // true
1031
+ type StrGreaterEq = TS.GTE<'b', 'b'>; // true
867
1032
  ```
868
1033
 
869
1034
  ---
@@ -960,6 +1125,26 @@ type Single = TS.String.SplitToChars<'A'>; // ['A']
960
1125
  type Multiple = TS.String.SplitToChars<'AB'>; // ['A', 'B']
961
1126
  ```
962
1127
 
1128
+ #### `TS.String.Split<S, Separator>`
1129
+
1130
+ Split string literal into substrings array by `Separator`.
1131
+
1132
+ **Type Parameters:**
1133
+ - `S` - String literal to split
1134
+ - `Separator` - ASCII character to split by
1135
+
1136
+ **Returns:** Array of string literal substrings
1137
+
1138
+ **Example:**
1139
+ ```typescript
1140
+ import { TS } from '@avstantso/ts';
1141
+
1142
+ type Empty = TS.String.Split<'', ASCII.Character>; // ['']
1143
+ type Pipe = TS.String.Split<'A|B', '|'>; // ['A', 'B']
1144
+ type NoMatch = TS.String.Split<'A|B', ','>; // ['A|B']
1145
+ type CSV = TS.String.Split<'First,Next', ','>; // ['First', 'Next']
1146
+ ```
1147
+
963
1148
  ### String Manipulation Types
964
1149
 
965
1150
  #### `TS.String.Repeat<S, N>`
@@ -1524,7 +1709,7 @@ const stringified = mapObjectValues(user, (key, value) => {
1524
1709
 
1525
1710
  ---
1526
1711
 
1527
- ## TS.Boolean
1712
+ ## Boolean Logic Types
1528
1713
 
1529
1714
  Boolean type utilities and logical operations.
1530
1715
 
@@ -1540,7 +1725,7 @@ type Yes = TS.If<true, 'yes', 'no'>; // 'yes'
1540
1725
  type No = TS.If<false, 'yes', 'no'>; // 'no'
1541
1726
  ```
1542
1727
 
1543
- ### `TS.If.And<Conditions, IfTrue = true, IfFalse = false>`
1728
+ ### `TS.And<Conditions, IfTrue = true, IfFalse = false>`
1544
1729
 
1545
1730
  Logical AND on array of conditions.
1546
1731
 
@@ -1548,11 +1733,11 @@ Logical AND on array of conditions.
1548
1733
  ```typescript
1549
1734
  import { TS } from '@avstantso/ts';
1550
1735
 
1551
- type AllTrue = TS.If.And<[true, true, true]>; // true
1552
- type OneFalse = TS.If.And<[true, false, true]>; // false
1736
+ type AllTrue = TS.And<[true, true, true]>; // true
1737
+ type OneFalse = TS.And<[true, false, true]>; // false
1553
1738
  ```
1554
1739
 
1555
- ### `TS.If.Or<Conditions, IfTrue = true, IfFalse = false>`
1740
+ ### `TS.Or<Conditions, IfTrue = true, IfFalse = false>`
1556
1741
 
1557
1742
  Logical OR on array of conditions.
1558
1743
 
@@ -1560,11 +1745,11 @@ Logical OR on array of conditions.
1560
1745
  ```typescript
1561
1746
  import { TS } from '@avstantso/ts';
1562
1747
 
1563
- type HasTrue = TS.If.Or<[false, true, false]>; // true
1564
- type AllFalse = TS.If.Or<[false, false, false]>; // false
1748
+ type HasTrue = TS.Or<[false, true, false]>; // true
1749
+ type AllFalse = TS.Or<[false, false, false]>; // false
1565
1750
  ```
1566
1751
 
1567
- ### `TS.If.Xor<Conditions, IfTrue = true, IfFalse = false>`
1752
+ ### `TS.Xor<Conditions, IfTrue = true, IfFalse = false>`
1568
1753
 
1569
1754
  Logical XOR on array of conditions (true if exactly one condition is true).
1570
1755
 
@@ -1572,9 +1757,9 @@ Logical XOR on array of conditions (true if exactly one condition is true).
1572
1757
  ```typescript
1573
1758
  import { TS } from '@avstantso/ts';
1574
1759
 
1575
- type OnlyOne = TS.If.Xor<[false, true, false]>; // true
1576
- type Multiple = TS.If.Xor<[true, true, false]>; // false
1577
- type None = TS.If.Xor<[false, false, false]>; // false
1760
+ type OnlyOne = TS.Xor<[false, true, false]>; // true
1761
+ type Multiple = TS.Xor<[true, true, false]>; // false
1762
+ type None = TS.Xor<[false, false, false]>; // false
1578
1763
  ```
1579
1764
 
1580
1765
  ---
@@ -2211,7 +2396,7 @@ type OnlyType = TS.Resolve<{ T: Function }>; // Function
2211
2396
 
2212
2397
  ---
2213
2398
 
2214
- ## TS Utility Types
2399
+ ## Utility Types
2215
2400
 
2216
2401
  Miscellaneous utility types for advanced type manipulation.
2217
2402
 
@@ -97,6 +97,31 @@ declare namespace AVStantso.TS.String {
97
97
  * type l2 = CheckType<SplitToChars<'AB'>, ['A', 'B']>;
98
98
  */
99
99
  export type SplitToChars<S extends string> = S extends undefined ? S : _SplitToChars<S>;
100
+ /**
101
+ * @summary Split `string` literal to substrings array by `Separator`.\
102
+ * ⚠ Unsafe, internal
103
+ * @example
104
+ * type n = CheckType<_Split<never, never>, never>;
105
+ * type u = CheckType<_Split<undefined, never>, [undefined]>; // ⚠
106
+ *
107
+ * type l0 = CheckType<_Split<'', ASCII.Character>, ['']>;
108
+ * type l1 = CheckType<_Split<'A|B', '|'>, ['A', 'B']>;
109
+ * type l2 = CheckType<_Split<'A|B', ','>, ['A|B']>;
110
+ * type l3 = CheckType<_Split<'First,Next', ','>, ['First', 'Next']>;
111
+ */
112
+ export type _Split<S extends string, Separator extends ASCII.Character, R extends string[] = []> = S extends `${infer C}${Separator}${infer E}` ? _Split<E, Separator, [...R, C]> : [...R, S];
113
+ /**
114
+ * @summary Split `string` literal to substrings array by `Separator`
115
+ * @example
116
+ * type n = CheckType<Split<never, never>, never>;
117
+ * type u = CheckType<Split<undefined, never>, []>;
118
+ *
119
+ * type l0 = CheckType<Split<'', ASCII.Character>, ['']>;
120
+ * type l1 = CheckType<Split<'A|B', '|'>, ['A', 'B']>;
121
+ * type l2 = CheckType<Split<'A|B', ','>, ['A|B']>;
122
+ * type l3 = CheckType<Split<'First,Next', ','>, ['First', 'Next']>;
123
+ */
124
+ export type Split<S extends string, Separator extends ASCII.Character> = S extends undefined ? S : Separator extends undefined ? Separator : _Split<S, Separator>;
100
125
  type _Repeat<S extends Possible, N extends number, R extends string = ''> = N extends 0 ? R : _Repeat<S, Decrement<N>, `${R}${S}`>;
101
126
  /**
102
127
  * @summary Repeat string possible `S` by `N` times
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@avstantso/ts",
3
3
  "license": "MIT",
4
4
  "author": "avstantso",
5
- "version": "1.3.1",
5
+ "version": "1.3.3",
6
6
  "description": "TypeScript helpers",
7
7
  "keywords": [
8
8
  "TypeScript"