Skip to content

Commit 7b33bb4

Browse files
committed
Written a little README.
1 parent 97d0ca5 commit 7b33bb4

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

README.md

+59-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,59 @@
1-
# etz-string-formatter
2-
Formats and validates strings against arbitrary patterns
1+
# Enterprize String Formatter
2+
Formats and validates strings against arbitrary patterns.
3+
4+
# Mask Characters
5+
6+
Character | Description
7+
--- | ---
8+
`0` | Any numbers
9+
`9` | Any numbers (Optional)
10+
`#` | Any numbers (recursive)
11+
`A` | Any alphanumeric character
12+
`a` | Any alphanumeric character (Optional) __Not implemented yet__
13+
`S` | Any letter
14+
`U` | Any letter (All lower case character will be mapped to uppercase)
15+
`L` | Any letter (All upper case character will be mapped to lowercase)
16+
`$` | Escape character, used to escape any of the special formatting characters.
17+
18+
# Usage
19+
20+
## Examples
21+
22+
### Currency Masking
23+
24+
```typescript
25+
26+
const currencyFormatter: StringFormatter = new StringFormatter("R$ #.##0,00", {reverse: true});
27+
const currency: string = "2538792";
28+
const formattedCurrency: string = currencyFormatter.apply(currency);
29+
30+
expect(formattedCurrency).to.equal("R$ 25.387,92");
31+
```
32+
33+
### Percentage
34+
35+
```typescript
36+
37+
const percentFormatter: StringFormatter = new StringFormatter("#.##0,00%", {reverse: true});
38+
const percentage: string = "3821";
39+
const formattedPercentage: string = percentFormatter.apply(percentage);
40+
41+
expect(formattedPercentage).to.equal("38,21%");
42+
```
43+
44+
### Number
45+
46+
```typescript
47+
48+
const numberFormatter: StringFormatter = new StringFormatter("#.##0", {reverse: true});
49+
const number: string = "1854";
50+
const formattedNumber: string = numberFormatter.apply(number);
51+
52+
expect(formattedNumber).to.equal("1.854");
53+
```
54+
55+
# Sponsor
56+
57+
Use my packages in your projects? You think they are awesome? So, help me give more time to develop them by becoming a sponsor. :wink:
58+
59+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8KT6SPVB84XLY&source=url"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="PayPal - The safer, easier way to pay online!"></a>

src/string-formatter.spec.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("String Formatter", () => {
1212
const currency: string = "2538792";
1313
const formattedCurrency: string = currencyFormatter.apply(currency);
1414

15-
expect(formattedCurrency).to.equal("R$ 25.387,92")
15+
expect(formattedCurrency).to.equal("R$ 25.387,92");
1616
});
1717

1818
it("Percentage", () => {
@@ -21,7 +21,7 @@ describe("String Formatter", () => {
2121
const percentage: string = "3821";
2222
const formattedPercentage: string = percentFormatter.apply(percentage);
2323

24-
expect(formattedPercentage).to.equal("38,21%")
24+
expect(formattedPercentage).to.equal("38,21%");
2525
});
2626

2727
it("Number", () => {
@@ -30,8 +30,7 @@ describe("String Formatter", () => {
3030
const number: string = "1854";
3131
const formattedNumber: string = numberFormatter.apply(number);
3232

33-
expect(formattedNumber).to.equal("1.854")
33+
expect(formattedNumber).to.equal("1.854");
3434
});
3535
});
36-
3736
});

0 commit comments

Comments
 (0)