persian-toman
v1.0.0
Published
Simple yet powerful package for converting Rial numbers to Toman and vise versa.
Maintainers
Readme
persian-toman
Format and convert Persian Rial and Toman prices using blazingly fast implementation which is flexible at the same time.
To install:
npm i persian-tomanUsage with ESM:
import { rialToToman, tomanToRial, rialToTomanNumber, tomanToRialNumber } from 'persian-toman'Usage with CJS:
const { rialToToman, tomanToRial, rialToTomanNumber, tomanToRialNumber } = require("persian-toman")Formatting and converting a Rial price to Toman:
const rial = 69_000
const toman = rialToToman(rial) // '۶٫۹۰۰ تومان'Same for the opposite side:
const toman = 69_000
const rial = tomanToRial(toman) // '۶۹۰٫۰۰۰ ریال'Convert just numbers using shorthand methods:
const price = 85_000
const toman = rialToTomanNumber(price) // 8500
const rial = tomanToRialNumber(price) // 850000The rialToToman and tomanToRial functions have an optional second argument for modifying the ouput format.
You can opt out of delimiter:
const price = 85_000
const toman = rialToToman(price, { delimiter: false }) // '۸۵۰۰ تومان'Also, you can opt out of Persian digit conversion:
const price = 85_000
const toman = rialToToman(price, { faDigits: false }) // '8,500 تومان'And you can modify the suffix:
const price = 85_000
const toman = rialToToman(price, { suffix: false }) // '۸٫۵۰۰'Or change it:
const price = 85_000
const toman = rialToToman(price, { suffix: ' ت' }) // '۸٫۵۰۰ ت'You are able to combine options as well:
const price = 85_000
const toman = rialToToman(price, { faDigits: false, suffix: ' IRT' }) // '8,500 IRT'Development
This project was created using bun init. Bun is a fast all-in-one JavaScript runtime.
To install dependencies:
bun installTo bundle:
bun run buildGenerate types:
tscLint without applying:
bun lintLint with applying safe fixes and formatting:
bun formatRun unit tests:
bun test --concurrent --randomizeIn order to publish the package:
npm loginCreate a tarball and check before publishing:
bun pm packPublish to npm:
bun publish