Skip to content

Commit efa722c

Browse files
refactor(Wrapper): change the Txt generic type variable to CustomText in the wrapOn() instance method, remove unnecessary generic type variables in the unwrapText() method. Update jsdoc.
1 parent 0629e79 commit efa722c

File tree

1 file changed

+51
-53
lines changed

1 file changed

+51
-53
lines changed

src/lib/wrapper.class.ts

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -140,49 +140,51 @@ export class Wrapper<
140140
/**
141141
* Determines whether the provided `text` has the closing chars of the specified `Wrapper` object at the end.
142142
* @param text The text of `string` to test for the existence of the closing chars at the end of it.
143-
* @returns The return value is a `boolean` indicating whether the given `text` has the closing of the wrap.
143+
* @returns The return value is a `boolean` indicating whether the given `text` has the closing chars of the wrap.
144144
* @angularpackage
145145
*/
146146
public isClosingIn(text: string): boolean {
147147
return Wrapper.hasClosing(text, this.closing);
148148
}
149149

150150
/**
151-
* Checks whether the provided `text` has the opening of a specified `Wrapper` object at the beginning.
151+
* Checks whether the provided `text` has the opening chars of a specified `Wrapper` object at the beginning.
152152
* @param text The text of `string` to test for the existence of the opening chars at the beginning of it.
153-
* @returns The return value is a `boolean` indicating whether the given `text` has the opening of the wrap.
153+
* @returns The return value is a `boolean` indicating whether the given `text` has the opening chars of the wrap.
154154
* @angularpackage
155155
*/
156156
public isOpeningIn(text: string): boolean {
157157
return Wrapper.hasOpening(text, this.opening);
158158
}
159159

160160
/**
161-
* Replaces the closing chars of the `Wrapper` object in the given text with a given replacement value.
161+
* Replaces the closing chars of the `Wrapper` object in the given `text` with a given replacement value.
162+
* The replacement succeeds if the closing characters exist at the end of the text.
162163
* @param text The text of `string` type in which the closing chars are replaced by given replacement value.
163164
* @param replaceValue The value of `string` type as a replacement for the closing chars at the end of the given `text`.
164-
* @returns The return value is the text of a `string` type with replaced closing chars by given replacement value.
165+
* @returns The return value is the text of `string` type with replaced closing chars by given replacement value.
165166
* @angularpackage
166167
*/
167168
public replaceClosingIn(text: string, replaceValue: string): string {
168169
return Wrapper.replaceClosing(text, this.closing, replaceValue);
169170
}
170171

171172
/**
172-
* Replaces the opening chars of the `Wrapper` object in the given text with a given replacement value.
173+
* Replaces the opening chars of the `Wrapper` object in the given `text` with a given replacement value.
174+
* The replacement succeeds if the opening characters exist at the beginning of the text.
173175
* @param text The text of `string` type in which the opening chars are replaced by given replacement value.
174176
* @param replaceValue The value of `string` type as a replacement for the opening chars at the beginning of the given `text`.
175-
* @returns The return value is the text of a `string` type with replaced opening chars by given replacement value.
177+
* @returns The return value is the text of `string` type with replaced opening chars by given replacement value.
176178
* @angularpackage
177179
*/
178180
public replaceOpeningIn(text: string, replaceValue: string): string {
179181
return Wrapper.replaceOpening(text, this.opening, replaceValue);
180182
}
181183

182184
/**
183-
* Returns given text without the opening and closing chars of the wrapper.
185+
* Returns given `text` without the opening and closing chars of the `Wrapper` object.
184186
* @param text The text of a `string` type to unwrap with the opening and closing chars of the `Wrapper` object.
185-
* @returns The return value is the unwrapped text from the opening and closing chars of a `string` type.
187+
* @returns The return value is the text of `string` type unwrapped from the opening and closing chars of the `Wrapper` object.
186188
* @angularpackage
187189
*/
188190
public removeWrapIn(text: string): string {
@@ -194,17 +196,19 @@ export class Wrapper<
194196
}
195197

196198
/**
197-
* Replaces the closing chars of the `Wrapper` object in the text with the given closing chars.
199+
* Replaces the closing chars of the `Wrapper` object in the text of the `Wrapper` object with the given `closing` chars.
200+
* The replacement succeeds if the closing characters exist at the end of the text.
198201
* @param closing The closing chars of `string` to replace in the text(part of the primitive value).
199-
* @returns The return value is the text of string type with replaced closing chars.
202+
* @returns The return value is the text of `string` type with replaced closing chars.
200203
* @angularpackage
201204
*/
202205
public textReplaceClosing(closing: string): string {
203206
return Wrapper.replaceClosing(this.text, this.closing, closing);
204207
}
205208

206209
/**
207-
* Replaces the opening chars of the `Wrapper` object in the text with the given opening chars.
210+
* Replaces the opening chars of the `Wrapper` object in the text of the `Wrapper` object with the given `opening` chars. The replacement
211+
* succeeds if the opening characters exist at the beginning of the text.
208212
* @param opening The opening chars of `string` to replace in the text(part of the primitive value).
209213
* @returns The return value is the text of string type with replaced opening chars.
210214
* @angularpackage
@@ -214,29 +218,27 @@ export class Wrapper<
214218
}
215219

216220
/**
217-
* The method returns the text of the `Wrapper` object without the opening and closing chars.
218-
* @param opening The opening chars of the generic type variable `CustomOpening` to remove from the beginning of the text of the `Wrapper`
219-
* instance. By default, its value is from the opening chars of an instance of `Wrapper`.
220-
* @param closing The closing chars of the generic type variable `CustomClosing` to remove from the end of the text of the `Wrapper`
221-
* instance. By default, its value is from the closing chars of an instance of `Wrapper`.
222-
* @returns The return value is the text of string type without the opening and closing chars.
221+
* The method returns the text of the `Wrapper` object without its opening and closing chars or the given `opening` and `closing` chars.
222+
* @param opening Optional opening chars of `string` type to remove from the beginning of the text of the `Wrapper` instance. By default,
223+
* its value is equal to the opening chars of the `Wrapper` instance.
224+
* @param closing Optional closing chars of `string` type to remove from the end of the text of the `Wrapper` instance. By default, its
225+
* value is equal to the closing chars of the `Wrapper` instance.
226+
* @returns The return value is the text of `string` type without the opening and closing chars of the `Wrapper` object or given `opening`
227+
* and `closing` chars.
223228
* @angularpackage
224229
*/
225-
public textUnwrap<
226-
CustomOpening extends string = Opening,
227-
CustomClosing extends string = Closing
228-
>(
229-
opening: CustomOpening = this.opening as any,
230-
closing: CustomClosing = this.closing as any
230+
public textUnwrap(
231+
opening: string = this.opening,
232+
closing: string = this.closing
231233
): string {
232234
return Wrapper.unwrap(this.text, opening, closing);
233235
}
234236

235237
/**
236-
* The method returns the text of the `Wrapper` object wrapped by the given opening and closing chars.
238+
* The method returns the text of the `Wrapper` object wrapped by the given `opening` and `closing` chars.
237239
* @param opening The opening chars of a generic type variable `TextOpening` to wrap the text of the `Wrapper` instance.
238240
* @param closing The closing chars of a generic type variable `TextClosing` to wrap the text of the `Wrapper` instance.
239-
* @returns The return value is wrapped text by given opening and closing chars of generic type `Wrapped`.
241+
* @returns The return value is the text wrapped by given `opening` and closing `chars` of generic type `Wrapped`.
240242
* @angularpackage
241243
*/
242244
public textWrap<TextOpening extends string, TextClosing extends string>(
@@ -274,37 +276,33 @@ export class Wrapper<
274276
}
275277

276278
/**
277-
* The method returns the primitive value of a specified `Wrapper` object with unwrapped text from its opening and closing chars or the
278-
* given `opening` and `closing` chars.
279-
* @param opening The opening chars of the generic type variable `CustomOpening` to remove from the beginning of the text of the `Wrapper`
280-
* instance. By default, its value is from the opening chars of an instance of `Wrapper`.
281-
* @param closing The closing chars of the generic type variable `CustomClosing` to remove from the end of the text of the `Wrapper`
282-
* instance. By default, its value is from the closing chars of an instance of `Wrapper`.
283-
* @returns The return value is the primitive value of `string` type with unwrapped text from its opening and closing chars or from the
284-
* given `opening` and `closing` chars.
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.
281+
* @param opening Optional opening chars of `string` type to remove from the beginning of the text of the `Wrapper` instance. By default,
282+
* its value is equal to the opening chars of the `Wrapper` instance.
283+
* @param closing Optional closing chars of `string` type to remove from the end of the text of the `Wrapper` instance. By default, its
284+
* value is equal to the closing chars of the `Wrapper` instance.
285+
* @returns The return value is the primitive value of `string` type with text unwrapped from the opening and closing chars of the
286+
* `Wrapper` object or the given `opening` and `closing` chars.
285287
* @angularpackage
286288
*/
287-
public unwrapText<
288-
CustomOpening extends string = Opening,
289-
CustomClosing extends string = Closing
290-
>(
291-
opening: CustomOpening = this.opening as any,
292-
closing: CustomClosing = this.closing as any
289+
public unwrapText(
290+
opening: string = this.opening,
291+
closing: string = this.closing
293292
): string {
294293
return `${this.opening}${Wrapper.unwrap(this.text, opening, closing)}${
295294
this.closing
296295
}`;
297296
}
298297

299298
/**
300-
* The method wraps the primitive value of a specified `Wrapper` object by its opening and closing chars or the given `opening` and
301-
* `closing` chars.
302-
* @param opening The opening chars of a generic type variable `CustomOpening` to wrap the primitive value of the `Wrapper` instance. By
303-
* default, its value is from the opening chars of an instance of `Wrapper`.
304-
* @param closing The closing chars of a generic type variable `CustomClosing` to wrap the primitive value of the `Wrapper` instance. By
305-
* default, its value is from the closing chars of an instance of `Wrapper`.
306-
* @returns The return value is the wrapped primitive value by the given opening and closing chars or the opening and closing chars of the
307-
* `Wrapper` instance.
299+
* The method wraps the primitive value of a specified `Wrapper` object by its opening and closing chars or given `opening` and `closing`
300+
* chars.
301+
* @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.
303+
* @param closing Optional closing chars of a generic type variable `CustomClosing` to wrap the primitive value of the `Wrapper` instance.
304+
* 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.
308306
* @angularpackage
309307
*/
310308
public wrap<
@@ -319,13 +317,13 @@ export class Wrapper<
319317

320318
/**
321319
* Wraps given text with the wrap, the opening, and closing chars of the `Wrapper` object.
322-
* @param text The text of generic type variable `Txt` to wrap by the opening and closing chars of the `Wrapper` instance.
323-
* @returns The return value is the wrapped text by the opening and closing chars of the `Wrapper` object of the generic type `Wrapped`.
320+
* @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`.
324322
* @angularpackage
325323
*/
326-
public wrapOn<Txt extends string = ''>(
327-
text: Txt
328-
): Wrapped<Opening, Txt, Closing> {
324+
public wrapOn<CustomText extends string = ''>(
325+
text: CustomText
326+
): Wrapped<Opening, CustomText, Closing> {
329327
return new Wrap(this.opening, this.closing, text).valueOf();
330328
}
331329

0 commit comments

Comments
 (0)