import {MarketType} from "../type"; import {MarketTypePrice} from './MarketTypePrice'; import {getMammonPrices} from './mammon'; const BATCH_SIZE = 100; export const getPrice = async (type: MarketType, locationId?: number): Promise => (await getPrices([type], locationId))[0]; export const getPrices = async (types: MarketType[], locationId?: number): Promise => { const batches: Promise[] = []; for (let i = 0; i < types.length; i += BATCH_SIZE) { batches.push(getMammonPrices(types.slice(i, i + BATCH_SIZE), locationId)); } return (await Promise.all(batches)).flat(); };