Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mavihq/pnumber
persian number utilities for javascript
https://github.com/mavihq/pnumber
convert english farsi javascript nodejs number persian word
Last synced: 3 months ago
JSON representation
persian number utilities for javascript
- Host: GitHub
- URL: https://github.com/mavihq/pnumber
- Owner: mavihq
- License: mit
- Created: 2017-05-05T14:01:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-26T12:16:30.000Z (over 7 years ago)
- Last Synced: 2024-07-09T18:44:18.829Z (4 months ago)
- Topics: convert, english, farsi, javascript, nodejs, number, persian, word
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-persian - pnumber - Persian number utilities for javascript. (JavaScript)
README
# pnumber
persian number utilities for javascript## features
+ Convert number to word
+ Convert number to word in Rials
+ Convert number to word in Tomans
+ Convert persian number to english number in string
+ Convert english number to persian number in string
+ Get only numbers from string
+ Parse persian phone numbers from given string
+ Validate persian phone numbers
+ Switch persian chars to english chars
+ Switch english chars to persian chars## Usage
es5
```
const pnumber = require('pnumber')const number = '123456'
console.log(pnumber.toWord(number))
console.log(pnumber.toWordRials(number))
console.log(pnumber.toWordTomans(number))
console.log(pnumber.toPersianDigits(number))
console.log(pnumber.toEnglishDigits('۱۲۳۴'))
console.log(pnumber.toEnglishDigits('۶۳ ن ۵۵۷ ایران ۱۱'))+++++++++
output:
یکصد بیست سه هزار چهارصد پنجاه شش
یکصد و بیست و سه هزار و چهارصد و پنجاه و شش ریال
دوازده هزار و سیصد و چهل و پنج تومان
۱۲۳۴۵۶
1234
63 ن 557 ایران 11
```es6
```
import {
toWord,
toWordRials,
toWordTomans,
toEnglishDigits,
toPersianDigits
} from 'pnumber'const number = '123456'
console.log(toWord(number))
console.log(toWordRials(number))
console.log(toWordTomans(number))
console.log(toPersianDigits(number))
console.log(toEnglishDigits('۱۲۳۴'))
console.log(toEnglishDigits('۶۳ ن ۵۵۷ ایران ۱۱'))+++++++++
output:
یکصد بیست سه هزار چهارصد پنجاه شش
یکصد و بیست و سه هزار و چهارصد و پنجاه و شش ریال
د
دوازده هزار و سیصد و چهل و پنج تومان
۱۲۳۴۵۶
1234
63 ن 557 ایران 11
```