lucid-ui
Version:
A UI component library from AppNexus.
13 lines • 554 B
JavaScript
import _clamp from "lodash/clamp";
import _isNumber from "lodash/isNumber";
export function totalPagesSelector(_ref) {
var pageSizeOptions = _ref.pageSizeOptions,
selectedPageSizeIndex = _ref.selectedPageSizeIndex,
totalCount = _ref.totalCount,
totalPages = _ref.totalPages;
var pageSize = pageSizeOptions[selectedPageSizeIndex];
return _isNumber(totalPages) ? totalPages : totalCount <= pageSize ? 1 : Math.floor(totalCount / pageSize) + _clamp(totalCount % pageSize, 0, 1);
}
export default {
totalPages: totalPagesSelector
};