1- // @angular -package/type.
2- import {
3- isStringLength ,
4- isStringType ,
5- isInstance ,
6- } from '@angular-package/type' ;
71/**
82 * The `Wrap` object represents the immutable text wrapped by the opening and closing chars. It is designed to preserve the names of the
93 * opening, text and closing.
@@ -79,8 +73,10 @@ export class Wrap<
7973 */
8074 public static hasClosing ( text : string , closing : string ) : boolean {
8175 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 &&
8480 text . slice ( - closing . length ) === closing
8581 ) ;
8682 }
@@ -94,8 +90,10 @@ export class Wrap<
9490 */
9591 public static hasOpening ( text : string , opening : string ) : boolean {
9692 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 &&
9997 text . slice ( 0 , opening . length ) === opening
10098 ) ;
10199 }
@@ -120,10 +118,10 @@ export class Wrap<
120118 closing ?: Closing ,
121119 text ?: Text
122120 ) : 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 )
127125 : false ;
128126 }
129127 //#endregion static public methods.
@@ -181,8 +179,8 @@ export class Wrap<
181179 */
182180 public hasClosing ( closing ?: string ) : boolean {
183181 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 )
186184 ) ;
187185 }
188186
@@ -195,8 +193,8 @@ export class Wrap<
195193 */
196194 public hasOpening ( opening ?: string ) : boolean {
197195 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 )
200198 ) ;
201199 }
202200
@@ -209,8 +207,8 @@ export class Wrap<
209207 */
210208 public hasText ( text ?: string ) : boolean {
211209 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 )
214212 ) ;
215213 }
216214
0 commit comments