Use loop instead of find (better RN support) (#80)

This commit is contained in:
Jaco Greeff
2019-02-19 08:16:15 +01:00
committed by GitHub
parent 15bff679dd
commit bb72e218b6
+8 -1
View File
@@ -36,5 +36,12 @@ export function calcSi (text: string, decimals: number): SiDef {
// Given a SI type (e.g. k, m, Y) find the SI definition
export function findSi (type: string): SiDef {
return SI.find(({ value }) => value === type) || SI[SI_MID];
// use a loop here, better RN support (which doesn't have [].find)
for (let i = 0; i < SI.length; i++) {
if (SI[i].value === type) {
return SI[i];
}
}
return SI[SI_MID];
}