1
- // @angular -package/type.
2
- import {
3
- isStringLength ,
4
- isStringType ,
5
- isInstance ,
6
- } from '@angular-package/type' ;
7
1
/**
8
2
* The `Wrap` object represents the immutable text wrapped by the opening and closing chars. It is designed to preserve the names of the
9
3
* opening, text and closing.
@@ -79,8 +73,10 @@ export class Wrap<
79
73
*/
80
74
public static hasClosing ( text : string , closing : string ) : boolean {
81
75
return (
82
- isStringLength ( text , { min : 1 } ) &&
83
- isStringLength ( closing , { min : 1 } ) &&
76
+ typeof text === 'string' &&
77
+ text . length >= 1 &&
78
+ typeof closing === 'string' &&
79
+ closing . length >= 1 &&
84
80
text . slice ( - closing . length ) === closing
85
81
) ;
86
82
}
@@ -94,8 +90,10 @@ export class Wrap<
94
90
*/
95
91
public static hasOpening ( text : string , opening : string ) : boolean {
96
92
return (
97
- isStringLength ( text , { min : 1 } ) &&
98
- isStringLength ( opening , { min : 1 } ) &&
93
+ typeof text === 'string' &&
94
+ text . length >= 1 &&
95
+ typeof opening === 'string' &&
96
+ opening . length >= 1 &&
99
97
text . slice ( 0 , opening . length ) === opening
100
98
) ;
101
99
}
@@ -120,10 +118,10 @@ export class Wrap<
120
118
closing ?: Closing ,
121
119
text ?: Text
122
120
) : value is Wrap < Opening , Text , Closing > {
123
- return isInstance ( value , this )
124
- ? ( isStringType ( opening ) ? opening === value . opening : true ) &&
125
- ( isStringType ( closing ) ? closing === value . closing : true ) &&
126
- ( isStringType ( text ) ? text === value . text : true )
121
+ return typeof value === 'object' && value instanceof this
122
+ ? ( typeof opening === 'string' ? opening === value . opening : true ) &&
123
+ ( typeof closing === 'string' ? closing === value . closing : true ) &&
124
+ ( typeof text === 'string' ? text === value . text : true )
127
125
: false ;
128
126
}
129
127
//#endregion static public methods.
@@ -181,8 +179,8 @@ export class Wrap<
181
179
*/
182
180
public hasClosing ( closing ?: string ) : boolean {
183
181
return (
184
- isStringLength ( this . #closing, { min : 1 } ) &&
185
- ( isStringType ( closing ) ? this . #closing === closing : true )
182
+ this . #closing. length >= 1 &&
183
+ ( typeof closing === 'string' ? this . #closing === closing : true )
186
184
) ;
187
185
}
188
186
@@ -195,8 +193,8 @@ export class Wrap<
195
193
*/
196
194
public hasOpening ( opening ?: string ) : boolean {
197
195
return (
198
- isStringLength ( this . #opening, { min : 1 } ) &&
199
- ( isStringType ( opening ) ? this . #opening === opening : true )
196
+ this . #opening. length >= 1 &&
197
+ ( typeof opening === 'string' ? this . #opening === opening : true )
200
198
) ;
201
199
}
202
200
@@ -209,8 +207,8 @@ export class Wrap<
209
207
*/
210
208
public hasText ( text ?: string ) : boolean {
211
209
return (
212
- isStringLength ( this . #text, { min : 1 } ) &&
213
- ( isStringType ( text ) ? this . #text === text : true )
210
+ this . #text. length >= 1 &&
211
+ ( typeof text === 'string' ? this . #text === text : true )
214
212
) ;
215
213
}
216
214
0 commit comments