2.1.0 • Published 4 months ago

@smakss/convert-numbers v2.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 months ago

Convert Numbers

npm NPM npm npm bundle size (scoped)

Convert Numbers is a utility package designed to ensure consistency in data transfer by converting Arabic and Persian numerals to English numerals. This tool is essential when user inputs might originate from different keyboard settings, requiring standardization of all digits to English format before further processing or database storage.

Demo

Check out the working demo on CodeSandbox:

View @smakss/convert-numbers

Installation

Install the package using npm or yarn:

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

Usage

Import convertNumbers into your project as a CommonJS or ECMAScript module:

ECMAScript Modules:

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

Then, use the function like this:

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

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

// Returns an empty string for no input
console.log(ConvertNumbers());

Features

  • Robust conversion: Utilizes a mapping approach for efficiency and readability, with a fallback to regular expressions for longer strings.
  • Error resilience: In case of unforeseen errors or compatibility issues, the function gracefully falls back to a basic for-of loop iteration.
  • Wide compatibility: Designed to work across a variety of JavaScript environments.

Documentation

For more detailed examples and information about the function usage, refer to the JSDoc comments in the source code.

Contributing

We welcome contributions! For guidelines on how to contribute, please check CONTRIBUTING.md.

Code of Conduct

We are committed to fostering a welcoming and positive community. Please see our Code of Conduct for more information.

2.1.0

4 months ago

2.1.0-beta.0

4 months ago

2.0.3

6 months ago

2.0.2

6 months ago

2.0.5

5 months ago

2.0.4

6 months ago

2.0.1

6 months ago

2.0.0

6 months ago

2.0.5-rc.0

5 months ago

2.0.0-beta.0

6 months ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.24

3 years ago

1.2.23

3 years ago

1.2.22

3 years ago

1.2.21

3 years ago

1.2.20

3 years ago

1.2.19

3 years ago

1.2.18

3 years ago

1.2.17

3 years ago

1.2.16

3 years ago

1.2.15

3 years ago

1.2.14

3 years ago

1.2.13

3 years ago

1.2.12

3 years ago

1.2.11

3 years ago

1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago