1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-08 17:02:30 +02:00
TableFilter/src/helpers.js
2016-05-25 17:31:53 +10:00

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