@@ -29,46 +29,10 @@ THE SOFTWARE.
2929import { Guard } from '../guard/index.ts'
3030
3131// ------------------------------------------------------------------
32- // StartsWith
33- // ------------------------------------------------------------------
34- type TStartsWith < Input extends string , Value extends string > = (
35- Input extends `${Value } ${string } `
36- ? true
37- : false
38- )
39- function StartsWith < Input extends string , Value extends string >
40- ( input : Input , value : Value ) :
41- TStartsWith < Input , Value > {
42- return Guard . IsEqual ( input . indexOf ( value ) , 0 ) as never
43- }
44- // ------------------------------------------------------------------
45- // IsWhitespace
46- // ------------------------------------------------------------------
47- export type TWhitespace = typeof Whitespace
48- export const Whitespace = ' '
49-
50- export type TIsWhitespace < Input extends string > = (
51- TStartsWith < Input , TWhitespace >
52- )
53- export function IsWhitespace < Input extends string > ( input : Input ) : TIsWhitespace < Input > {
54- return StartsWith ( input , Whitespace ) as never
55- }
56- // ------------------------------------------------------------------
57- // IsNewline
58- // ------------------------------------------------------------------
59- export type TNewline = typeof Newline
60- export const Newline = '\n'
61-
62- export type TIsNewline < Input extends string > = (
63- TStartsWith < Input , TNewline >
64- )
65- export function IsNewline < Input extends string > ( input : Input ) : TIsNewline < Input > {
66- return StartsWith ( input , Newline ) as never
67- }
68- // ------------------------------------------------------------------
69- // IsAlpha
32+ // Alphas
7033// ------------------------------------------------------------------
7134export type TAlpha = typeof Alpha
35+
7236export const Alpha = [
7337 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' ,
7438 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' ,
@@ -78,85 +42,34 @@ export const Alpha = [
7842 'Y' , 'Z'
7943] as const
8044
81- export type TIsAlpha < Input extends string > = (
82- TStartsWith < Input , TAlpha [ number ] >
83- )
84- export function IsAlpha < Input extends string > ( input : Input ) : TIsAlpha < Input > {
85- const charCode = input . charCodeAt ( 0 )
86- return (
87- ( Guard . IsGreaterEqualThan ( charCode , 65 ) && Guard . IsLessEqualThan ( charCode , 90 ) ) // A-Z
88- || ( Guard . IsGreaterEqualThan ( charCode , 97 ) && Guard . IsLessEqualThan ( charCode , 122 ) ) // a-z
89- ) as never
90- }
9145// ------------------------------------------------------------------
92- // IsDigit
46+ // Digits
9347// ------------------------------------------------------------------
48+ export type TNonZero = typeof NonZero
49+ export type TZero = typeof Zero
9450export type TDigit = typeof Digit
95- export const Digit = [
96- '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9'
97- ] as const
98- export type TIsDigit < Input extends string > = (
99- TStartsWith < Input , TDigit [ number ] >
100- )
101- export function IsDigit < Input extends string > ( input : Input ) : TIsDigit < Input > {
102- return (
103- IsNonZero ( input ) || IsZero ( input )
104- ) as never
105- }
106- // ------------------------------------------------------------------
107- // IsZero
108- // ------------------------------------------------------------------
109- export type TIsZero < Input extends string > = (
110- TStartsWith < Input , '0' >
111- )
112- export function IsZero < Input extends string > ( input : Input ) : boolean {
113- const charCode = input . charCodeAt ( 0 )
114- return Guard . IsEqual ( charCode , 48 )
115- }
116- // ------------------------------------------------------------------
117- // IsNonZero
118- // ------------------------------------------------------------------
119- export type TIsNonZero < Input extends string > = (
120- TStartsWith < Input , Exclude < TDigit [ number ] , '0' > >
121- )
122- export function IsNonZero < Input extends string > ( input : Input ) : boolean {
123- const charCode = input . charCodeAt ( 0 )
124- return Guard . IsGreaterEqualThan ( charCode , 49 )
125- && Guard . IsLessEqualThan ( charCode , 57 )
126- }
127- // ------------------------------------------------------------------
128- // IsDot
129- // ------------------------------------------------------------------
130- export type TDot = typeof Dot
131- export const Dot = '.'
13251
133- export type TIsDot < Input extends string > = (
134- TStartsWith < Input , TDot >
135- )
136- export function IsDot < Input extends string > ( input : Input ) : TIsDot < Input > {
137- return StartsWith ( input , Dot )
138- }
139- // ------------------------------------------------------------------
140- // IsUnderscore
141- // ------------------------------------------------------------------
142- export type TUnderscore = typeof Underscore
143- export const Underscore = '_'
52+ export const NonZero = [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' ] as const
53+ export const Zero = '0'
54+ export const Digit = [ Zero , ...NonZero ] as const
14455
145- export type TIsUnderscore < Input extends string > = (
146- TStartsWith < Input , TUnderscore >
147- )
148- export function IsUnderscore < Input extends string > ( input : Input ) : TIsUnderscore < Input > {
149- return StartsWith ( input , Underscore )
150- }
15156// ------------------------------------------------------------------
152- // IsDollarSign
57+ // Characters
15358// ------------------------------------------------------------------
154- export type TDollarSign = typeof DollarSign
59+ export const Whitespace = ' '
60+ export const Newline = '\n'
61+ export const Underscore = '_'
62+ export const Dot = '.'
15563export const DollarSign = '$'
64+ export const SingleQuote = "'"
65+ export const DoubleQuote = '"'
66+ export const Backtick = "`"
15667
157- export type TIsDollarSign < Input extends string > = (
158- TStartsWith < Input , TDollarSign >
159- )
160- export function IsDollarSign < Input extends string > ( input : Input ) : TIsDollarSign < Input > {
161- return StartsWith ( input , DollarSign )
162- }
68+ export type TWhitespace = typeof Whitespace
69+ export type TNewline = typeof Newline
70+ export type TUnderscore = typeof Underscore
71+ export type TDot = typeof Dot
72+ export type TDollarSign = typeof DollarSign
73+ export type TSingleQuote = typeof SingleQuote
74+ export type TDoubleQuote = typeof DoubleQuote
75+ export type TBacktick = typeof Backtick
0 commit comments