UNPKG

@lifi/widget

Version:

LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.

23 lines 766 B
/** * We use <0.01% for both small positive and negative changes to keep it simple and clear, focusing on minimal impact rather than direction. * Examples: * +0.007% -> <0.01% * -0.003% -> <0.01% */ export const percentFormatter = (lng, options) => { const formatter = new Intl.NumberFormat(lng, { ...options, style: 'percent', }); return (value) => { if ((value > 0 && value < 0.0001) || (value < 0 && value > -0.0001)) { return `<${formatter.format(0.0001)}`; } const formattedValue = formatter.format(value); if (options?.usePlusSign && value > 0) { return `+${formattedValue}`; } return formattedValue; }; }; //# sourceMappingURL=percentFormatter.js.map