mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-10 09:52:33 +02:00
20 lines
448 B
JavaScript
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;
|
|
}
|