more refactoring ✨
This commit is contained in:
@@ -10,6 +10,39 @@ export const GetWinLoss = (matchResult, teamId) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const truncate = (str, len, ending) => {
|
||||
if (len == null)
|
||||
len = 100
|
||||
|
||||
if (ending == null)
|
||||
ending = '..'
|
||||
|
||||
if (str.length > len)
|
||||
return str.substring(0, len - ending.length) + ending
|
||||
else
|
||||
return str
|
||||
}
|
||||
|
||||
export const checkStatEmpty = (stat) => {
|
||||
if (stat)
|
||||
return stat
|
||||
return 0
|
||||
}
|
||||
|
||||
export const getPlayerArr = (stats, team) => {
|
||||
let arr = []
|
||||
for (let i = (team - 1) * 5; i < team * 5; i++) {
|
||||
arr.push({
|
||||
value: truncate(stats[i].player.name, 15),
|
||||
textStyle: {
|
||||
color: 'white'
|
||||
}
|
||||
})
|
||||
}
|
||||
arr.reverse()
|
||||
return arr
|
||||
}
|
||||
|
||||
export const TrackMe = async (id64, authcode, sharecode) => {
|
||||
let statusError = ''
|
||||
let status = 200
|
||||
|
||||
@@ -4,7 +4,7 @@ import {SaveLastVisitedToLocalStorage} from "./LocalStorage";
|
||||
import {GetHLTV_1} from "./HLTV";
|
||||
import {DisplayRank, LoadImage} from "./Display";
|
||||
import {GetUser} from "./ApiRequests";
|
||||
import {GetWinLoss, TrackMe} from "./Utils";
|
||||
import {GetWinLoss, TrackMe, truncate, checkStatEmpty, getPlayerArr} from "./Utils";
|
||||
|
||||
export {
|
||||
FormatDate, FormatFullDuration, FormatFullDate, FormatDuration,
|
||||
@@ -13,5 +13,5 @@ export {
|
||||
GetHLTV_1,
|
||||
DisplayRank, LoadImage,
|
||||
GetUser,
|
||||
GetWinLoss, TrackMe
|
||||
GetWinLoss, TrackMe, truncate, checkStatEmpty, getPlayerArr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user