one-separator-decimal-mask
v0.0.6
Published
Converts input value to a string with separator decimal passed as paramater, locale is irrelevant. Using one-separator-decimal.
Downloads
3
Readme
one-separator-decimal-mask
- Converts input value to a string with separator decimal passed as paramater, locale is irrelevant. Using one-separator-decimal.
Install
npm install one-separator-decimal-mask
Usage
import mask from 'one-separator-decimal-mask'
...
/**
* @license MIT License
* @param {String} input
* @param {String} [separator='.'] The separator is optional, default value is a dot.
*
*/
let result = mask('10,,')
//result = "10"
Validations
NaN
√ should return "" when the value is `test`
Integer number input values
√ should return "10" when the value is `10`
Floating number input values
√ should return "10.0" when the value is `10,0`
√ should return "10.0" when the value is `10.0`
√ should return "10.60" when the value is `10.60`
√ should return "10.601" when the value is `10.601`
Last index is not a number
√ should return "10." when the value is `10,`
√ should return "10." when the value is `10.`
√ should return "10." when the value is `10,,`
√ should return "10." when the value is `10..`
√ should return "1000." when the value is `10,00,`
√ should return "1000." when the value is `10.00.00`
Second dot or comma
√ should return "1000.01" when the value is `10,00,01`
√ should return "1000.01" when the value is `10.00.01`
License
MIT License