Changeset View
Changeset View
Standalone View
Standalone View
apps/ecash-herald/src/utils.js
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | formatPrice: function (price, fiatCode) { | ||||
})}`; | })}`; | ||||
} | } | ||||
// All decimal places for lower prices | // All decimal places for lower prices | ||||
// For now, these will only be XEC prices | // For now, these will only be XEC prices | ||||
return `${fiatSymbol}${price.toLocaleString('en-us', { | return `${fiatSymbol}${price.toLocaleString('en-us', { | ||||
maximumFractionDigits: 8, | maximumFractionDigits: 8, | ||||
})}`; | })}`; | ||||
}, | }, | ||||
jsonReplacer: function (key, value) { | |||||
if (value instanceof Map) { | |||||
return { | |||||
dataType: 'Map', | |||||
value: Array.from(value.entries()), | |||||
}; | |||||
} else if (value instanceof Set) { | |||||
return { | |||||
dataType: 'Set', | |||||
value: Array.from(value.keys()), | |||||
}; | |||||
} else { | |||||
return value; | |||||
} | |||||
}, | |||||
jsonReviver: function (key, value) { | |||||
if (typeof value === 'object' && value !== null) { | |||||
if (value.dataType === 'Map') { | |||||
return new Map(value.value); | |||||
} | |||||
if (value.dataType === 'Set') { | |||||
return new Set(value.value); | |||||
} | |||||
} | |||||
return value; | |||||
}, | |||||
}; | }; |