Skip to content

Commit 2bc12f3

Browse files
Merge pull request #6 from typescript-package/develop
v4.0.0
2 parents 0318343 + b72df46 commit 2bc12f3

22 files changed

+1287
-186
lines changed

README.md

Lines changed: 145 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<a href="https://www.typescriptlang.org/">
22
<img
33
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."
55
/>
66
</a>
77

@@ -12,15 +12,20 @@
1212
[![GitHub issues][typescript-package-badge-issues]][typescript-package-issues]
1313
[![GitHub license][typescript-package-badge-license]][typescript-package-license]
1414

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.
1618

1719
<br>
1820

1921
## Table of contents
2022

2123
- [Installation](#installation)
2224
- [Api](#api)
25+
- [`AffixCore`](#affixcore)
2326
- [`Affix`](#affix)
27+
- [`Circumfix`](#circumfix)
28+
- [`Infix`](#infix)
2429
- [`Prefix`](#prefix)
2530
- [`Suffix`](#suffix)
2631
- [Contributing](#contributing)
@@ -33,6 +38,14 @@ A **lightweight** TypeScript library for the affix - prefix and suffix.
3338

3439
## Installation
3540

41+
### 1. Install peer dependencies
42+
43+
```bash
44+
npm install @typedly/affix --save-peer
45+
```
46+
47+
### 2. Install the package
48+
3649
```bash
3750
npm install @typescript-package/affix --save-peer
3851
```
@@ -42,25 +55,141 @@ npm install @typescript-package/affix --save-peer
4255
```typescript
4356
import {
4457
// Abstract.
45-
Affix,
58+
AffixCore,
4659
// Class.
60+
Affix,
61+
Circumfix,
62+
Infix,
4763
Prefix,
48-
Suffix
64+
Suffix,
4965
} from '@typescript-package/affix';
5066
```
5167

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+
5282
### `Affix`
5383

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+
```
55136

56137
### `Prefix`
57138

58139
A class to manage prefixes that can be applied to strings.
59140

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+
60173
### `Suffix`
61174

62175
A class to manage suffixes that can be applied to strings.
63176

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+
64193
## Contributing
65194

66195
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:
73202

74203
- [Stripe](https://donate.stripe.com/dR614hfDZcJE3wAcMM)
75204
- [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)
76216

77217
Thanks for your support!
78218

package-lock.json

Lines changed: 66 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "@typescript-package/affix",
3-
"version": "2.1.0",
3+
"version": "4.0.0",
44
"author": "wwwdev.io <dev@wwwdev.io>",
5-
"description": "A lightweight TypeScript library for the affix - prefix and suffix.",
5+
"description": "A lightweight TypeScript library for different kind of affixes.",
66
"license": "MIT",
77
"publishConfig": {
88
"access": "public",
99
"registry": "https://registry.npmjs.org"
1010
},
1111
"peerDependencies": {
12-
"@typescript-package/core": "^2.0.0"
12+
"@typedly/affix": "^4.0.0"
1313
},
1414
"scripts": {
1515
"prepublishOnly": "npm run pkg && npm run clean",
@@ -29,7 +29,9 @@
2929
"Affix",
3030
"Prefix",
3131
"Suffix",
32-
"Value"
32+
"Value",
33+
"Circumfix",
34+
"Infix"
3335
],
3436
"funding": [
3537
{

0 commit comments

Comments
 (0)