diff --git a/src/market/appraisal/fuzzwork.ts b/src/market/appraisal/fuzzwork.ts index 02c400b..dde0ac9 100644 --- a/src/market/appraisal/fuzzwork.ts +++ b/src/market/appraisal/fuzzwork.ts @@ -23,14 +23,17 @@ export const getfuzzworkPrices: PriceGetter = async types => { return (await Promise.all(batches)) .flatMap(b => Object.entries(b.data)) .map(entry => { - const id = parseInt(entry[0]); + const id = doParseInt(entry[0]); const prices = entry[1] as any; return { type: types.find(t => t.id === id) as MarketType, - buy: parseFloat(prices.buy.max), - sell: parseFloat(prices.sell.min), - orderCount: parseInt(prices.buy.order_count) + parseInt(prices.sell.order_count) + buy: doParseFloat(prices?.buy?.max), + sell: doParseFloat(prices?.sell?.min), + orderCount: doParseInt(prices?.buy?.order_count) + doParseInt(prices?.sell?.order_count) } }); -}; \ No newline at end of file +}; + +const doParseInt = (s?: string) => s ? parseInt(s) : 0; +const doParseFloat = (s?: string) => s ? parseFloat(s) : 0;