@automattic/calypso-products
Version:
This module contains information about the various products sold within calypso, such as product slugs, plan intervals, etc.
23 lines • 778 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPriceTierForUnits = getPriceTierForUnits;
function getPriceTierForUnits(tiers, units) {
const firstUnboundedTier = tiers.find((tier) => !tier.maximum_units);
let matchingTier = tiers.find((tier) => {
if (!tier.maximum_units) {
return false;
}
if (units >= tier.minimum_units && units <= tier.maximum_units) {
return true;
}
return false;
});
if (!matchingTier && firstUnboundedTier && units >= firstUnboundedTier.minimum_units) {
matchingTier = firstUnboundedTier;
}
if (!matchingTier) {
return null;
}
return matchingTier;
}
//# sourceMappingURL=get-price-tier-for-units.js.map