2014-11-16 01:29:07 +01:00
|
|
|
/**
|
|
|
|
* Misc helpers
|
|
|
|
*/
|
|
|
|
|
2015-05-30 14:23:33 +02:00
|
|
|
import Str from './string';
|
2015-04-04 10:10:09 +02:00
|
|
|
|
2015-05-30 14:23:33 +02:00
|
|
|
export default {
|
2016-05-07 06:33:17 +02:00
|
|
|
removeNbFormat(data, format) {
|
|
|
|
if (!data) {
|
2015-03-01 11:44:39 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-05-07 06:33:17 +02:00
|
|
|
if (!format) {
|
2015-03-01 11:44:39 +01:00
|
|
|
format = 'us';
|
|
|
|
}
|
2015-05-30 14:23:33 +02:00
|
|
|
let n = data;
|
2016-05-07 06:33:17 +02:00
|
|
|
if (Str.lower(format) === 'us') {
|
|
|
|
n = + n.replace(/[^\d\.-]/g, '');
|
2015-03-01 11:44:39 +01:00
|
|
|
} else {
|
2016-05-07 06:33:17 +02:00
|
|
|
n = + n.replace(/[^\d\,-]/g, '').replace(',', '.');
|
2015-03-01 11:44:39 +01:00
|
|
|
}
|
|
|
|
return n;
|
2014-11-16 01:29:07 +01:00
|
|
|
}
|
|
|
|
};
|