lion/packages/localize/src/number/forceSpaceInsteadOfZeroForGroup.js
Joren Broekema 09d9675963 feat(localize): add types to localize
Co-authored-by: narzac <narzac@gmail.com>
2020-08-03 17:00:26 +02:00

16 lines
527 B
JavaScript

/**
* @desc Intl uses 0 as group separator for bg-BG locale.
* This should be a ' '
*
* @typedef {import('../../types/LocalizeMixinTypes').FormatNumberPart} FormatNumberPart
* @param {FormatNumberPart[]} formattedParts
* @returns {FormatNumberPart[]} corrected formatted parts
*/
export function forceSpaceInsteadOfZeroForGroup(formattedParts) {
return formattedParts.map(p => {
if (p.type === 'group' && p.value === '0') {
p.value = ' '; // eslint-disable-line no-param-reassign
}
return p;
});
}