1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-17 05:46:39 +02:00
TableFilter/src/helpers.js

20 lines
448 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') => {
let n = data;
if (format.toLowerCase() === 'us') {
n = + n.replace(/[^\d\.-]/g, '');
} else {
n = + n.replace(/[^\d\,-]/g, '').replace(',', '.');
}
return n;
}