UNPKG

steamcommunity-inventory

Version:

A rate limit and response handler for steamcommunity inventories. - It's functional. - Will appreciate all feedback I can get

20 lines (19 loc) 654 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNextCount = void 0; const constant_1 = require("./constant"); /** * Gets count for next request via new method. * * @return {number} */ function getNextCount({ desiredMoreAmount, currentAmount, totalAmount, }) { const howMuchMore = desiredMoreAmount - currentAmount; const howMuchLeft = totalAmount - currentAmount; if (howMuchMore <= constant_1.REQUEST_COUNT_THRESHOLD) return howMuchMore; if (howMuchLeft > howMuchMore) return desiredMoreAmount; return howMuchLeft; } exports.getNextCount = getNextCount;