Have ideas to improve npm?Join in the discussion! »

    @smakss/convert-numbers

    1.3.1 • Public • Published

    Convert numbers

    npm Snyk Vulnerabilities for npm package NPM npm npm bundle size (scoped)

    Due to keeping consistency in our data transfer with API's we need to make sure digits or numbers entered by user inputs have always transferred by English. Since users could always fill data with different keyboard settings we need to make sure that we don't send Arabic or Persian numbers to our database. So to avoid such an inconsistency we should always translate our numbers or prevent a user from entering unwanted data. Convert numbers created for this cause to make sure every digit input is in standard format of it.

    How it works?

    To install it you can simply do the following command:

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

    to include it with common js module you should do this:

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

    and to include it with ECMAscript module you can simply do this one:

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

    then to use it within your application you can do it just like this:

    ConvertNumbers(); 
    
    // Result: undefined 
    // If you don't provide any input it will return undefined.
    ConvertNumbers('۱۲۳۴۵۶۷۸۹۰');
    
    // Result: '1234567890'
    ConvertNumbers('١٢٣٤٥٦٧٨٩٠');
    
    // Result: '1234567890'

    Demo

    You can check the working demo in runkit.

    Install

    npm i @smakss/convert-numbers

    DownloadsWeekly Downloads

    2

    Version

    1.3.1

    License

    MIT

    Unpacked Size

    5.45 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar