Skip to content

Commit b72df46

Browse files
docs(README.md): update.
1 parent 61343ca commit b72df46

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues]
1313
[![GitHub license][typescript-package-badge-license]][typescript-package-license]
1414

15-
**version**: v3.0.0
15+
**version**: v4.0.0
1616

1717
A **lightweight** TypeScript library for different kind of affixes.
1818

@@ -99,6 +99,15 @@ A class to manage circumfixes that can be applied to strings.
9999
```typescript
100100
import { Circumfix } from '@typescript-package/affix';
101101

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'
102111
```
103112

104113
### `Infix`
@@ -108,6 +117,21 @@ A class to manage infixes that can be applied to strings.
108117
```typescript
109118
import { Infix } from '@typescript-package/affix';
110119

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'
111135
```
112136

113137
### `Prefix`
@@ -117,7 +141,33 @@ A class to manage prefixes that can be applied to strings.
117141
```typescript
118142
import { Prefix } from '@typescript-package/affix';
119143

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+
121171
```
122172

123173
### `Suffix`
@@ -126,6 +176,18 @@ A class to manage suffixes that can be applied to strings.
126176

127177
```typescript
128178
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+
129191
```
130192

131193
## Contributing

0 commit comments

Comments
 (0)