1
1
<a href =" https://www.typescriptlang.org/ " >
2
2
<img
3
3
src="https://avatars.githubusercontent.com/u/189666396?s=150&u=9d55b1eb4ce258974ead76bf07ccf49ef0eb0ea7&v=4 "
4
- title="@typescript-package/affix "
4
+ title="@typescript-package - The typescript package enhances the development of typescript-based applications by providing well-structured, reusable, easy-to-use packages. "
5
5
/>
6
6
</a >
7
7
12
12
[ ![ GitHub issues] [ typescript-package-badge-issues ]] [ typescript-package-issues ]
13
13
[ ![ GitHub license] [ typescript-package-badge-license ]] [ typescript-package-license ]
14
14
15
- A ** lightweight** TypeScript library for the affix - prefix and suffix.
15
+ ** version** : v4.0.0
16
+
17
+ A ** lightweight** TypeScript library for different kind of affixes.
16
18
17
19
<br >
18
20
19
21
## Table of contents
20
22
21
23
- [ Installation] ( #installation )
22
24
- [ Api] ( #api )
25
+ - [ ` AffixCore ` ] ( #affixcore )
23
26
- [ ` Affix ` ] ( #affix )
27
+ - [ ` Circumfix ` ] ( #circumfix )
28
+ - [ ` Infix ` ] ( #infix )
24
29
- [ ` Prefix ` ] ( #prefix )
25
30
- [ ` Suffix ` ] ( #suffix )
26
31
- [ Contributing] ( #contributing )
@@ -33,6 +38,14 @@ A **lightweight** TypeScript library for the affix - prefix and suffix.
33
38
34
39
## Installation
35
40
41
+ ### 1. Install peer dependencies
42
+
43
+ ``` bash
44
+ npm install @typedly/affix --save-peer
45
+ ```
46
+
47
+ ### 2. Install the package
48
+
36
49
``` bash
37
50
npm install @typescript-package/affix --save-peer
38
51
```
@@ -42,25 +55,141 @@ npm install @typescript-package/affix --save-peer
42
55
``` typescript
43
56
import {
44
57
// Abstract.
45
- Affix ,
58
+ AffixCore ,
46
59
// Class.
60
+ Affix ,
61
+ Circumfix ,
62
+ Infix ,
47
63
Prefix ,
48
- Suffix
64
+ Suffix ,
49
65
} from ' @typescript-package/affix' ;
50
66
```
51
67
68
+ ### ` AffixCore `
69
+
70
+ A core ` abstract ` class to manage affixes with the value and kind that can be applied to strings.
71
+
72
+ ``` typescript
73
+ import { AffixCore } from ' @typescript-package/affix' ;
74
+
75
+ class Prefix extends AffixCore <string , ' prefix' > {
76
+ constructor (value : string ) {
77
+ super (value , ' prefix' );
78
+ }
79
+ }
80
+ ```
81
+
52
82
### ` Affix `
53
83
54
- A class to manage affixes (prefixes or suffixes) that can be applied to strings.
84
+ A concrete class to manage affixes that can be applied to strings with additional sanitization.
85
+
86
+ ``` typescript
87
+ import { Affix } from ' @typescript-package/affix' ;
88
+
89
+ export const prefix = new Affix (" testAffixValue" , {
90
+ kind: ' prefix' as BasicAffixKind ,
91
+ pattern: / [^ a-zA-Z0-9 $_] / g ,
92
+ });
93
+ ```
94
+
95
+ ### ` Circumfix `
96
+
97
+ A class to manage circumfixes that can be applied to strings.
98
+
99
+ ``` typescript
100
+ import { Circumfix } from ' @typescript-package/affix' ;
101
+
102
+ const circumfix = new Circumfix (
103
+ ' pre' , // Start
104
+ ' post' , // End
105
+ / [^ a-zA-Z0-9 $_] / g // Pattern
106
+ );
107
+
108
+ circumfix .insertTo (
109
+ ' light' // Stem
110
+ ); // 'prelightpost'
111
+ ```
112
+
113
+ ### ` Infix `
114
+
115
+ A class to manage infixes that can be applied to strings.
116
+
117
+ ``` typescript
118
+ import { Infix } from ' @typescript-package/affix' ;
119
+
120
+ const infix = new Infix (' en' );
121
+
122
+ infix .insertTo (
123
+ ' light' , // stem
124
+ 5 // position
125
+ ); // 'lighten'
126
+ infix .insertTo (
127
+ ' light' , // stem
128
+ 0 // position
129
+ ); // 'enlight'
130
+ infix .insertTo (
131
+ ' light' , // stem
132
+ 1 , // position
133
+ ' -' // delimiter
134
+ ); // 'l-en-ight'
135
+ ```
55
136
56
137
### ` Prefix `
57
138
58
139
A class to manage prefixes that can be applied to strings.
59
140
141
+ ``` typescript
142
+ import { Prefix } from ' @typescript-package/affix' ;
143
+
144
+ const prefix = new Prefix (
145
+ ' pre' , // Value
146
+ / [^ a-zA-Z0-9 $_] / g // Pattern
147
+ );
148
+
149
+ prefix .prependTo (
150
+ ' stem' , // stem
151
+ ' -' // delimiter
152
+ ); // 'pre-stem'
153
+
154
+ console .debug (` default => ` , Prefix .default ); // ''
155
+ console .debug (` pattern => ` , Prefix .pattern ); // RegExp /[^a-zA-Z0-9$_]/g
156
+ console .debug (` tagName => ` , Prefix .tagName ); // 'Prefix'
157
+
158
+ console .debug (` kind => ` , prefix .kind ); // 'prefix'
159
+ console .debug (` pattern => ` , prefix .pattern ); // RegExp /[^a-zA-Z0-9$_]/g
160
+ console .debug (` prefix => ` , prefix .prefix ); // 'pre'
161
+ console .debug (` toStringTag => ` , prefix [Symbol .toStringTag ]); // 'Prefix'
162
+ console .debug (` value => ` , prefix .value ); // 'pre'
163
+
164
+ console .debug (` prefix.get() ` , prefix .get ()); // 'pre'
165
+ console .debug (` prefix.set({value: 'newPrefix'}) => ` , prefix .set ({value: ' newPrefix' as any }).value ); // 'newPrefix'
166
+
167
+ console .debug (` prefix.setKind('newKind') => ` , prefix .setKind (' newKind' as any ).kind ); // 'newKind'
168
+ console .debug (` prefix.setPattern(/newPattern/g) => ` , prefix .setPattern (/ newPattern/ g ).pattern ); // /newPattern/g
169
+ console .debug (` prefix.setValue('newValue') => ` , prefix .setValue (' newValue' as any ).value ); // 'newValue'
170
+
171
+ ```
172
+
60
173
### ` Suffix `
61
174
62
175
A class to manage suffixes that can be applied to strings.
63
176
177
+ ``` typescript
178
+ import { Suffix } from ' @typescript-package/affix' ;
179
+
180
+ export const suffix = new Suffix (
181
+ ' post' , // Value
182
+ / [^ a-zA-Z0-9 $_] / g // Pattern
183
+ );
184
+
185
+ Suffix .append (
186
+ ' stem' ,
187
+ ' post' ,
188
+ ' -'
189
+ ); //
190
+
191
+ ```
192
+
64
193
## Contributing
65
194
66
195
Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.
@@ -73,6 +202,17 @@ Support via:
73
202
74
203
- [ Stripe] ( https://donate.stripe.com/dR614hfDZcJE3wAcMM )
75
204
- [ Revolut] ( https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29 )
205
+ - [ GitHub] ( https://github.com/sponsors/angular-package/sponsorships?sponsor=sciborrudnicki&tier_id=83618 )
206
+ - [ DonorBox] ( https://donorbox.org/become-a-sponsor-to-the-angular-package?default_interval=o )
207
+ - [ Patreon] ( https://www.patreon.com/checkout/angularpackage?rid=0&fan_landing=true&view_as=public )
208
+
209
+ or via Trust Wallet
210
+
211
+ - [ XLM] ( https://link.trustwallet.com/send?coin=148&address=GAFFFB7H3LG42O6JA63FJDRK4PP4JCNEOPHLGLLFH625X2KFYQ4UYVM4 )
212
+ - [ USDT (BEP20)] ( https://link.trustwallet.com/send?coin=20000714&address=0xA0c22A2bc7E37C1d5992dFDFFeD5E6f9298E1b94&token_id=0x55d398326f99059fF775485246999027B3197955 )
213
+ - [ ETH] ( https://link.trustwallet.com/send?coin=60&address=0xA0c22A2bc7E37C1d5992dFDFFeD5E6f9298E1b94 )
214
+ - [ BTC] ( https://link.trustwallet.com/send?coin=0&address=bc1qnf709336tfl57ta5mfkf4t9fndhx7agxvv9svn )
215
+ - [ BNB] ( https://link.trustwallet.com/send?coin=20000714&address=0xA0c22A2bc7E37C1d5992dFDFFeD5E6f9298E1b94 )
76
216
77
217
Thanks for your support!
78
218
0 commit comments