2014-11-16 01:29:07 +01:00
|
|
|
/**
|
|
|
|
* Misc helpers
|
|
|
|
*/
|
|
|
|
|
2016-05-25 09:31:53 +02:00
|
|
|
/**
|
|
|
|
* Returns a unformatted number
|
|
|
|
* @param {String} Formatted number
|
|
|
|
* @param {String} Format type, currently 'us' or 'eu'
|
|
|
|
* @return {String} Unformatted number
|
|
|
|
*/
|
2016-06-02 05:31:58 +02:00
|
|
|
export const removeNbFormat = (data, format = 'us') => {
|
2016-05-20 09:21:42 +02:00
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
2016-06-02 05:31:58 +02:00
|
|
|
|
2016-05-20 09:21:42 +02:00
|
|
|
let n = data;
|
|
|
|
if (format.toLowerCase() === 'us') {
|
|
|
|
n = + n.replace(/[^\d\.-]/g, '');
|
|
|
|
} else {
|
|
|
|
n = + n.replace(/[^\d\,-]/g, '').replace(',', '.');
|
2014-11-16 01:29:07 +01:00
|
|
|
}
|
2016-05-20 09:21:42 +02:00
|
|
|
return n;
|
|
|
|
}
|