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
- ** version** : v3 .0.0
15
+ ** version** : v4 .0.0
16
16
17
17
A ** lightweight** TypeScript library for different kind of affixes.
18
18
@@ -99,6 +99,15 @@ A class to manage circumfixes that can be applied to strings.
99
99
``` typescript
100
100
import { Circumfix } from ' @typescript-package/affix' ;
101
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'
102
111
```
103
112
104
113
### ` Infix `
@@ -108,6 +117,21 @@ A class to manage infixes that can be applied to strings.
108
117
``` typescript
109
118
import { Infix } from ' @typescript-package/affix' ;
110
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'
111
135
```
112
136
113
137
### ` Prefix `
@@ -117,7 +141,33 @@ A class to manage prefixes that can be applied to strings.
117
141
``` typescript
118
142
import { Prefix } from ' @typescript-package/affix' ;
119
143
120
- export const prefix = new Prefix ();
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
+
121
171
```
122
172
123
173
### ` Suffix `
@@ -126,6 +176,18 @@ A class to manage suffixes that can be applied to strings.
126
176
127
177
``` typescript
128
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
+
129
191
```
130
192
131
193
## Contributing
0 commit comments