Skip to content

Commit 174530d

Browse files
Merge pull request #1 from angular-package/0.0.x
0.0.x
2 parents b4dc2c5 + 9cc7db3 commit 174530d

File tree

3 files changed

+61
-89
lines changed

3 files changed

+61
-89
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Wrap the text with the opening and closing chars.
5858

5959
## Documentation
6060

61+
For the detailed documentation go to [**https://wrapper.angular-package.dev/**](https://wrapper.angular-package.dev/)
6162

6263
<br>
6364

@@ -157,7 +158,7 @@ How do I know when to release 1.0.0?
157158
158159
## License
159160

160-
MIT © angular-package ([license][text-license])
161+
MIT © angular-package ([license][wrapper-license])
161162

162163
<!-- Funding -->
163164
[github-badge-sponsor]: https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/angular-package

src/lib/wrapper.class.ts

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Wrapper<
4545
}
4646

4747
/**
48-
* The method checks if the value of any type is an instance of the `Wrapper` of any, or given opening and closing chars.
48+
* 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.
4949
* @param value The value of any type to test against the `Wrapper` instance.
5050
* @param opening Optional opening chars of generic type variable `Opening` to check if the given `value` contains.
5151
* @param closing Optional closing chars of generic type variable `Closing` to check if the given `value` contains.
@@ -70,10 +70,10 @@ 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 the closing chars in a given `text` with a given replacement value at the end of the 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.
76+
* @param replaceValue Replacement value for the given `closing` characters in the given `text`.
7777
* @returns The return value is the text of `string` type with a replaced closing chars by a given replacement value.
7878
* @angularpackage
7979
*/
@@ -88,10 +88,10 @@ export class Wrapper<
8888
}
8989

9090
/**
91-
* Replaces the opening chars in a given text with a given replacement value at the end of the text.
91+
* Replaces the opening chars in a given `text` with a given replacement value at the end of the text.
9292
* @param text The text of `string` type in which the given `opening` chars are replaced by a given replacement value.
9393
* @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.
94+
* @param replaceValue Replacement value for the `opening` characters in the given `text`.
9595
* @returns The return value is the text of `string` type with a replaced opening chars by a given replacement value.
9696
* @angularpackage
9797
*/
@@ -110,7 +110,7 @@ export class Wrapper<
110110
* @param text The text of the `string` from which given opening and closing chars are removed.
111111
* @param opening The opening chars of the `string` to be removed in the given `text`.
112112
* @param closing The closing chars of the `string` to be removed in the given `text`.
113-
* @returns The return value is the text without the given opening and closing chars.
113+
* @returns The return value is the text of string type without the given opening and closing chars.
114114
* @angularpackage
115115
*/
116116
public static unwrap(text: string, opening = '', closing = ''): string {
@@ -138,51 +138,53 @@ export class Wrapper<
138138

139139
//#region instance public methods.
140140
/**
141-
* Determines whether the provided `text` has the closing chars of the specified `Wrapper` object.
142-
* @param text The text of `string` to test for the existence of the closing chars at the end in it.
143-
* @returns The return value is a `boolean` indicating whether the given `text` has the closing of the wrap.
141+
* Determines whether the provided `text` has the closing chars of the specified `Wrapper` object at the end.
142+
* @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 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 if the provided `text` has the opening of a specified `Wrapper` object at the beginning of the text.
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

src/test/wrapper.spec.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,6 @@ import { Wrapper } from '../lib/wrapper.class';
77
const testing = new Testing(true, true);
88
const toBe = new TestingToBeMatchers();
99

10-
const w = new Wrapper('[', ']', '{my text}');
11-
12-
console.log(`---`);
13-
14-
console.log(w.wrap('<', '>'));
15-
console.log(w.wrapOn('my new text'));
16-
17-
console.log(w.wrapText('<', '>'));
18-
19-
console.log(w.isWrapped());
20-
console.log(w.isWrapped('['));
21-
console.log(w.isWrapped(undefined, ']'));
22-
console.log(w.isWrapped('[', ']'));
23-
24-
console.log(w.toWrap());
25-
console.log(w.removeWrapIn(w.valueOf()));
26-
console.log(w.unwrap());
27-
console.log(w.unwrapText());
28-
console.log(w.unwrapText('{', '}'));
29-
30-
console.log(`---`);
31-
32-
console.log(w.textReplaceClosing('<'));
33-
console.log(w.textReplaceOpening('>'));
34-
console.log(w.textUnwrap());
35-
console.log(w.textWrap('<', '>'));
36-
3710
testing.describe(`Wrapper`, () => {
3811
const opening = `<`;
3912
const replaceOpening = '{{';

0 commit comments

Comments
 (0)