Skip to content

Commit d8d0f4b

Browse files
refactor(Wrapper): update name toStringTag from the wrapper to Wrapper, change the default value for the generic type variable Text of the isWrapper() static method, remove the default values of the opening and closing parameters in the static unwrap() method, update jsdoc.
1 parent 44bd1f5 commit d8d0f4b

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/lib/wrapper.class.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class Wrapper<
1717
* `typeOf()` function of `@angular-package/type`.
1818
*/
1919
public get [Symbol.toStringTag](): string {
20-
return 'wrapper';
20+
return 'Wrapper';
2121
}
2222
//#endregion instance accessors.
2323

@@ -43,7 +43,7 @@ export class Wrapper<
4343
}
4444

4545
/**
46-
* The method checks if the value of any type is an instance of the `Wrapper` of any, or the given opening, closing chars, and text.
46+
* The method checks if the value of any type is an instance of the `Wrapper` of any, or the given `opening`, `closing` chars, and `text`.
4747
* @param value The value of any type to test against the `Wrapper` instance.
4848
* @param opening Optional opening chars of generic type variable `Opening` to check if the given `value` contains.
4949
* @param closing Optional closing chars of generic type variable `Closing` to check if the given `value` contains.
@@ -55,7 +55,7 @@ export class Wrapper<
5555
public static isWrapper<
5656
Opening extends string,
5757
Closing extends string,
58-
Text extends string = ''
58+
Text extends string = string
5959
>(
6060
value: any,
6161
opening?: Opening,
@@ -70,11 +70,12 @@ export class Wrapper<
7070
}
7171

7272
/**
73-
* Replaces the closing chars in a given `text` with a given replacement value at the end of the text.
73+
* Replaces given `closing` chars with a given replacement value at the end of the given `text`.
7474
* @param text The text of `string` type in which given `closing` characters are replaced by a given replacement value.
7575
* @param closing The closing chars of the `string` to replace by a given replacement value at the end of the given `text`.
76-
* @param replaceValue Replacement value for the given `closing` characters in the given `text`.
77-
* @returns The return value is the text of `string` type with a replaced closing chars by a given replacement value.
76+
* @param replaceValue The replacement value of a string type for the given `closing` characters in the given `text`.
77+
* @returns The return value is the given `text` of `string` type with a replaced `closing` chars by a given replacement value or the
78+
* specified `text` unchanged if it does not contain the given `closing` chars.
7879
* @angularpackage
7980
*/
8081
public static replaceClosing(
@@ -88,11 +89,12 @@ export class Wrapper<
8889
}
8990

9091
/**
91-
* Replaces the opening chars in a given `text` with a given replacement value at the beginning of the text.
92+
* Replaces given `opening` chars with a given replacement value at the beginning of the given `text`.
9293
* @param text The text of `string` type in which the given `opening` chars are replaced by a given replacement value.
9394
* @param opening The opening chars of the `string` to replace by a given replacement value at the beginning of the given `text`.
94-
* @param replaceValue Replacement value for the `opening` characters in the given `text`.
95-
* @returns The return value is the text of `string` type with a replaced opening chars by a given replacement value.
95+
* @param replaceValue The replacement value of a string type for the given `opening` characters in the given `text`.
96+
* @returns The return value is the given `text` of `string` type with a replaced `opening` chars by a given replacement value or the
97+
* specified `text` unchanged if it does not contain the given `opening` chars.
9698
* @angularpackage
9799
*/
98100
public static replaceOpening(
@@ -106,14 +108,15 @@ export class Wrapper<
106108
}
107109

108110
/**
109-
* The method returns the text without the given `opening` and `closing` chars.
111+
* The method returns the given `text` without the given `opening` and `closing` chars.
110112
* @param text The text of the `string` from which given opening and closing chars are removed.
111113
* @param opening The opening chars of the `string` to be removed in the given `text`.
112114
* @param closing The closing chars of the `string` to be removed in the given `text`.
113-
* @returns The return value is the text of string type without the given opening and closing chars.
115+
* @returns The return value is the given `text` of `string` type without the given `opening` and `closing` chars or unchanged `text` if
116+
* it does not contain the given `opening` and `closing` chars.
114117
* @angularpackage
115118
*/
116-
public static unwrap(text: string, opening = '', closing = ''): string {
119+
public static unwrap(text: string, opening: string, closing: string): string {
117120
return (
118121
(text = this.replaceClosing(text, closing, '')),
119122
(text = this.replaceOpening(text, opening, '')),
@@ -162,7 +165,7 @@ export class Wrapper<
162165
* The replacement succeeds if the closing characters exist at the end of the text.
163166
* @param text The text of `string` type in which the closing chars are replaced by given replacement value.
164167
* @param replaceValue The value of `string` type as a replacement for the closing chars at the end of the given `text`.
165-
* @returns The return value is the text of `string` type with replaced closing chars by given replacement value.
168+
* @returns The return value is the given `text` of `string` type with replaced closing chars by given replacement value.
166169
* @angularpackage
167170
*/
168171
public replaceClosingIn(text: string, replaceValue: string): string {
@@ -174,7 +177,7 @@ export class Wrapper<
174177
* The replacement succeeds if the opening characters exist at the beginning of the text.
175178
* @param text The text of `string` type in which the opening chars are replaced by given replacement value.
176179
* @param replaceValue The value of `string` type as a replacement for the opening chars at the beginning of the given `text`.
177-
* @returns The return value is the text of `string` type with replaced opening chars by given replacement value.
180+
* @returns The return value is the given `text` of `string` type with replaced opening chars by given replacement value.
178181
* @angularpackage
179182
*/
180183
public replaceOpeningIn(text: string, replaceValue: string): string {
@@ -183,7 +186,7 @@ export class Wrapper<
183186

184187
/**
185188
* Returns given `text` without the opening and closing chars of the `Wrapper` object.
186-
* @param text The text of a `string` type to unwrap with the opening and closing chars of the `Wrapper` object.
189+
* @param text The text of a `string` type to unwrap from the opening and closing chars of the `Wrapper` object.
187190
* @returns The return value is the text of `string` type unwrapped from the opening and closing chars of the `Wrapper` object.
188191
* @angularpackage
189192
*/
@@ -210,7 +213,7 @@ export class Wrapper<
210213
* Replaces the opening chars of the `Wrapper` object in the text of the `Wrapper` object with the given `opening` chars. The replacement
211214
* succeeds if the opening characters exist at the beginning of the text.
212215
* @param opening The opening chars of `string` to replace in the text(part of the primitive value).
213-
* @returns The return value is the text of string type with replaced opening chars.
216+
* @returns The return value is the text of `string` type with replaced opening chars.
214217
* @angularpackage
215218
*/
216219
public textReplaceOpening(opening: string): string {
@@ -276,8 +279,8 @@ export class Wrapper<
276279
}
277280

278281
/**
279-
* The method returns the primitive value of a specified `Wrapper` object with text unwrapped from its opening and closing chars or given
280-
* `opening` and `closing` chars.
282+
* The method returns the primitive value of a specified `Wrapper` object with text unwrapped from the opening and closing chars of the
283+
* `Wrapper` instance or given `opening` and `closing` chars.
281284
* @param opening Optional opening chars of `string` type to remove from the beginning of the text of the `Wrapper` instance. By default,
282285
* its value is equal to the opening chars of the `Wrapper` instance.
283286
* @param closing Optional closing chars of `string` type to remove from the end of the text of the `Wrapper` instance. By default, its
@@ -299,10 +302,11 @@ export class Wrapper<
299302
* The method wraps the primitive value of a specified `Wrapper` object by its opening and closing chars or given `opening` and `closing`
300303
* chars.
301304
* @param opening Optional opening chars of a generic type variable `CustomOpening` to wrap the primitive value of the `Wrapper` instance.
302-
* By default, its value is equal to the closing chars of the `Wrapper` instance.
305+
* By default, its value is equal to the opening chars of the `Wrapper` instance.
303306
* @param closing Optional closing chars of a generic type variable `CustomClosing` to wrap the primitive value of the `Wrapper` instance.
304307
* By default, its value is equal to the closing chars of the `Wrapper` instance.
305-
* @returns The return value is a primitive value wrapped by the given opening and closing chars or from the `Wrapper` instance.
308+
* @returns The return value is a primitive value wrapped by the opening and closing chars of the `Wrapper` instance or the given
309+
* `opening` and `closing` chars.
306310
* @angularpackage
307311
*/
308312
public wrap<
@@ -316,9 +320,10 @@ export class Wrapper<
316320
}
317321

318322
/**
319-
* Wraps given text with the wrap, the opening, and closing chars of the `Wrapper` object.
323+
* The method wraps the given `text` with the wrap, the `opening`, and `closing` chars of the `Wrapper` object.
320324
* @param text The text of generic type variable `CustomText` to wrap by the opening and closing chars of the `Wrapper` instance.
321-
* @returns The return value is the text wrapped by the opening and closing chars of the `Wrapper` object of the generic type `Wrapped`.
325+
* @returns The return value is the given `text` wrapped by the opening and closing chars of the `Wrapper` object of the generic type
326+
* `Wrapped`.
322327
* @angularpackage
323328
*/
324329
public wrapOn<CustomText extends string = ''>(

0 commit comments

Comments
 (0)