arabic-digits-converter
v1.0.2
Published
Convert numbers to their arabic counterpart and vice versa.
Downloads
5
Maintainers
Readme
:sparkles: arabic-digits-converter
Convert numbers to their arabic counterpart and vice versa.
:rocket: Installation
npm install arabic-digits-converter
yarn add arabic-digits-converter
:blue_book: Usage/Examples
toArabicDigit and fromArabicDigit, both take their second argument as intOnly, it decides whether to only send numbers back or not.
toArabicDigit.
- Convert numbers to their arabic counterpart.
import { toArabicDigit } from "arabic-numbers-converter";
const num = 1234567890;
// intOnly is defaulted to false.
toArabicDigit(num); // => ١٢٣٤٥٦٧٨٩٠
- Convert a paragraph with intOnly set to false.
import { toArabicDigit } from "arabic-numbers-converter";
const para =
"1 2 3 4 5 6 7 8 9 10 loream ipsum dolor s12323it am123123et, consectetasd123123ur adipiscin11g elit.";
// intOnly set to false.
toArabicDigit(para, false); // => ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ ١٠ loream ipsum dolor s١٢٣٢٣it am١٢٣١٢٣et, consectetasd١٢٣١٢٣ur adipiscin١١g elit.
- Convert a paragraph with intOnly set to true.
import { toArabicDigit } from "arabic-numbers-converter";
const para = "abcd 123 123 123";
// intOnly set to false.
toArabicDigit(para, true); // => ١٢٣١٢٣١٢٣
toArabicDigit(para, false); // => abcd ١٢٣ ١٢٣ ١٢٣
fromArabicDigit.
- Convert arabic numbers to their numeral counterpart.
import { fromArabicDigit } from "arabic-numbers-converter";
fromArabicDigit("١", false); // => 1
- Convert a paragraph with numbers in betweem
const paragraphWithArabicNumbers =
`١٢٣٤٥٦٧٨٩٠ lorem ipsum dolor sit amet, consectetur adipiscing elit.`;
fromArabicDigit(paragraphWithArabicNumbers); // => '1234567890 lorem ipsum dolor sit amet, consectetur adipiscing elit.'
- Convert a line with intOnly set to true
const paragraphWithArabicNumbers =
`١٢٣٤٥٦٧ ٨٩٠ lorem ipsum dolor s٢٣٤٥it amet, consec٨٩tetur adipisc٨٩ing elit.`;
fromArabicDigit(paragraphWithArabicNumbers, true); // => 123456789023458990
FAQs.
- If the input in fromArabicDigits is only of type number (or only contains arabic digits), or intOnly is set to true, then the output type will be of number.
Releasing
Under the hood, this library uses semantic-release and commitizen.
The goal is to avoid manual release process. Using semantic-release
will automatically create a github release (hence tags) as well as an npm release.
Based on your commit history, semantic-release
will automatically create a patch, feature or breaking release.
Commands:
semantic-release
: triggers a release (used in CI)