Skip to content

convert-numbers 2.0.3

Install from the command line:
Learn more about npm packages
$ npm install @SMAKSS/convert-numbers@2.0.3
Install via package.json:
"@SMAKSS/convert-numbers": "2.0.3"

About this version

Convert Numbers

npm NPM npm npm bundle size (scoped)

Convert Numbers is a utility package that helps ensure consistency in data transfer by converting Arabic and Persian numerals to English numerals. This is particularly useful when user inputs can come from different keyboard settings, and there's a need to standardize all digits to English format before sending data to a database or processing it further.

Demo

You can check the working demo on RunKit.

Or

View @smakss/convert-numbers

Installation

To install the package, you can use npm or yarn with the following commands:

npm i @smakss/convert-numbers
# or
yarn add @smakss/convert-numbers

Usage

Import the convertNumbers function into your project using CommonJS or ECMAScript modules:

CommonJS:

const ConvertNumbers = require('@smakss/convert-numbers');

ECMAScript Modules:

import ConvertNumbers from '@smakss/convert-numbers';

Then, use the function as follows:

// Returns '1234567890' for Persian numbers
console.log(ConvertNumbers('۱۲۳۴۵۶۷۸۹۰'));

// Returns '1234567890' for Arabic numbers
console.log(ConvertNumbers('١٢٣٤٥٦٧٨٩٠'));

// Returns "" for no input
console.log(ConvertNumbers());

Documentation

For more detailed examples and function usage, please refer to the JSDoc comments within the code.

Contributing

Contributions to the project are welcome! Please refer to CONTRIBUTING.md for contribution guidelines.

Code of Conduct

To maintain a welcoming and positive community, please see our Code of Conduct.

Details


Assets

  • convert-numbers-2.0.3.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0