Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Luc Didry
kresus
Commits
a75d9b6d
Commit
a75d9b6d
authored
Mar 12, 2019
by
Antoine
Browse files
Check the currency is known in the currency-related helpers.
parent
61fec0ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
shared/helpers.js
View file @
a75d9b6d
...
...
@@ -120,8 +120,16 @@ export const localeComparator = (function() {
export
const
currency
=
{
isKnown
:
c
=>
typeof
findCurrency
(
c
)
!==
'
undefined
'
,
symbolFor
:
c
=>
findCurrency
(
c
).
symbol
,
symbolFor
:
c
=>
{
if
(
!
currency
.
isKnown
(
c
))
{
throw
new
Error
(
`Unknown currency:
${
c
}
`
);
}
return
findCurrency
(
c
).
symbol
;
},
makeFormat
:
c
=>
{
if
(
!
currency
.
isKnown
(
c
))
{
throw
new
Error
(
`Unknown currency:
${
c
}
`
);
}
let
{
decimalDigits
}
=
findCurrency
(
c
);
return
amount
=>
{
let
am
=
Math
.
abs
(
amount
)
<
Math
.
pow
(
10
,
-
decimalDigits
-
2
)
?
0
:
amount
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment