1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-10 10:26:38 +02:00
TableFilter/src/helpers.js
2016-06-02 13:31:58 +10:00

24 lines
488 B
JavaScript

/**
* Misc helpers
*/
/**
* Returns a unformatted number
* @param {String} Formatted number
* @param {String} Format type, currently 'us' or 'eu'
* @return {String} Unformatted number
*/
export const removeNbFormat = (data, format = 'us') => {
if (!data) {
return;
}
let n = data;
if (format.toLowerCase() === 'us') {
n = + n.replace(/[^\d\.-]/g, '');
} else {
n = + n.replace(/[^\d\,-]/g, '').replace(',', '.');
}
return n;
}