Skip to content

A terminal-based converter that converts Arabic numerals to English numerals

Notifications You must be signed in to change notification settings

CodeWithOz/arabic2english

Repository files navigation

arabic2english Numerals Converter 🔄

A terminal-based converter that provides the written names for numbers (arabic numerals). For instance, 11 becomes 'eleven'.

Screenshot of terminal showing converter output

Usage

This package requires NodeJS and npm.

Clone the repository to your local machine using:

git clone https://github.com/CodeWithOz/arabic2english.git

Change into the newly created folder using:

cd arabic2english/

Run the arabic2english.js script using the node command, passing the desired number as the first argument:

$ node arabic2english.js 65
sixty-five

Limitations

The parser:

  • Only goes up to the quadrillions (18 digits), although higher numbers can easily be extended. See the Larger Than Quadrillions section for more information.
  • Only handles digits. Except for the minus sign at the beginning of the number (eg -908), no other non-digit characters are supported. Comma-formatted numbers (eg. 100,090) will yield unexpected results.

Developer set up

After cloning the repository, run npm install to install all dependencies.

Larger Than Quadrillions

To handle numbers larger than quadrillions, extend the setsMap object in the file (currently) located at ./helpers/largeNumbersParser/index.js by adding more keys from 7 and above. The parser will use your provided name(s) appropriately.

Testing

Jest is required to run the tests. With Jest installed, run npm test to see the test results.

Note: I used @babel/register to ensure compatibility of ES6 imports/exports with NodeJS' cli. Therefore, your terminal may display a nonsensical console.log statement when you run npm test.

About

A terminal-based converter that converts Arabic numerals to English numerals

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published