1 | [![NPM](https://nodei.co/npm/starkstring.png)](https://nodei.co/npm/starkstring/)
|
2 |
|
3 | [![install size](https://packagephobia.now.sh/badge?p=starkstring)](https://packagephobia.now.sh/result?p=starkstring) [![dependencies](https://david-dm.org/hosseinmd/starkstring.svg)](https://david-dm.org/hosseinmd/starkstring.svg)
|
4 |
|
5 |
|
6 | # [starkstring](http://github.com/hosseinmd/starkString)
|
7 | A simple JavaScript library To use the most commonly used string operations.
|
8 | Include functions of `persian.js`
|
9 |
|
10 | ## TOC
|
11 |
|
12 | * [install](#install)
|
13 | * [Functions](#Functions)
|
14 | * [Contributing](#Contributing)
|
15 |
|
16 |
|
17 | ## install
|
18 | `$ yarn add starkstring`
|
19 |
|
20 | ## Functions
|
21 |
|
22 | ### 1) Convert Arabic characters to Persian
|
23 |
|
24 | Used for converting Arabic characters to Persian.
|
25 |
|
26 | Example:
|
27 | ```javascript
|
28 | starkString(" علي ").trim().persianChar().toString(); //returns: علی
|
29 | ```
|
30 | ----------
|
31 |
|
32 | ### 2) Convert to English numbers from Persian and arabic Number
|
33 |
|
34 | Used for converting Persian and arabic Number to English numbers.
|
35 |
|
36 | Example:
|
37 | ```javascript
|
38 | starkString("۳۴۵ ٤٥").englishNumber().toString(); //returns: 345 45
|
39 | ```
|
40 | ----------
|
41 |
|
42 | ### 3) Convert to Persian numbers from Arabic and English Number
|
43 |
|
44 | Used for converting Arabic and English numbers to Persian.
|
45 |
|
46 | Example:
|
47 | ```javascript
|
48 | starkString("٣٤٥ 78").persianNumber().toString(); //returns: ۳۴۵ ۷۸
|
49 | ```
|
50 | ----------
|
51 |
|
52 | ### 4) Convert to Arabic numbers from English and Persian Number
|
53 |
|
54 | Used for converting Arabic and Persian numbers to English.
|
55 |
|
56 | Example:
|
57 | ```javascript
|
58 | starkString("345").arabicNumber().toString(); //returns: ٣٤٥
|
59 | ```
|
60 | ----------
|
61 |
|
62 | ### 6) Decode Percent-encoding Characters in URLs
|
63 |
|
64 | Used to convert unreadable Persian characters in URL to readable characters.
|
65 |
|
66 | Example:
|
67 | ```javascript
|
68 | starkString("https://fa.wikipedia.org/wiki/%D8%B5%D9%81%D8%AD%D9%87%D9%94_%D8%A7%D8%B5%D9%84%DB%8C").fixURL().toString(); //returns https://fa.wikipedia.org/wiki/صفحهٔ_اصلی
|
69 | ```
|
70 | ----------
|
71 |
|
72 | ### 7) Change keyboard layout
|
73 |
|
74 | Used for converting Persian char to English char.
|
75 |
|
76 | Example:
|
77 | ```javascript
|
78 | starkString("لخخلمث").switchKey().toString(); //returns: google
|
79 | ```
|
80 | ----------
|
81 |
|
82 | ### 8) Convert numbers to words
|
83 |
|
84 | Used for representing numbers as Persian words.
|
85 |
|
86 | Example:
|
87 | ```javascript
|
88 | starkString("1372").digitsToWords().toString(); //returns: یک هزار و سیصد و هفتاد و دو
|
89 | ```
|
90 | ----------
|
91 |
|
92 | ### 9) Zero-width non-joiner correction
|
93 |
|
94 | Example:
|
95 | ```javascript
|
96 | starkString("آمده ای ولی من رفته ام و می آییم").halfSpace().toString(); //returns: آمدهای ولی من رفتهام و میآییم
|
97 | ```
|
98 | ----------
|
99 |
|
100 | ### 10) Integer number validation
|
101 |
|
102 | Whether is value integer
|
103 |
|
104 | Example:
|
105 | ```javascript
|
106 | starkString("344327905").isInteger() // return true
|
107 |
|
108 | starkString("34432.7905").isInteger() // return false
|
109 | starkString("g344327905").isInteger() // return false
|
110 | ```
|
111 | ----------
|
112 |
|
113 | ### 11) bank card number validation
|
114 |
|
115 | Whether is value bank card
|
116 |
|
117 | Example:
|
118 | ```javascript
|
119 | starkString("6104337638408961").isValidBankCard() // return true
|
120 | ```
|
121 | ----------
|
122 |
|
123 | ### 12) convert number to currency format
|
124 |
|
125 | convert english number to currency format
|
126 |
|
127 | Example:
|
128 | ```javascript
|
129 | starkString("120000.00").currency().toString() // return 120,000.00
|
130 |
|
131 | starkString("120000").currency().persianNumber().toString() // return ۱۲۰,۰۰۰
|
132 | ```
|
133 | ----------
|
134 |
|
135 | ### 13) Parse Numbers
|
136 |
|
137 | Remove anything expect numbers
|
138 |
|
139 | Example:
|
140 | ```javascript
|
141 | starkString(" amount 12,000 dollar").parseNumber().toString() // return 12000
|
142 | ```
|
143 | ----------
|
144 |
|
145 | ### 14) security string
|
146 |
|
147 | convert any char to star ("*")
|
148 |
|
149 | Example:
|
150 | ```javascript
|
151 | starkString("password").security().toString() // return ********
|
152 | ```
|
153 | ----------
|
154 |
|
155 | ### Chainable using
|
156 |
|
157 | You can use all of the functions together with one StarkString instance.
|
158 |
|
159 | Example:
|
160 | ```javascript
|
161 | starkString("علي٤2465").persianChar().englishNumber().persianNumber().toString(); //returns: علی۴۲۴۶۵
|
162 | ```
|
163 | ----------
|
164 |
|
165 | ## Contributing
|
166 |
|
167 | This is a open-source project. Fork the project, complete the code and send pull request.
|