UNPKG

@applicaster/zapp-react-native-ui-components

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

20 lines (13 loc) 583 B
import * as R from "ramda"; export function itemLimitForData(entry = [], component) { const itemLimitValue = Number(R.path(["rules", "item_limit"], component)); const itemLimit = itemLimitValue && itemLimitValue > 0 ? itemLimitValue : Number.MAX_SAFE_INTEGER; const isInRange = (min, max) => R.both(R.gte(R.__, min), R.lt(R.__, max)); const entryShouldBeSliced = (entry) => isInRange(0, R.length(entry))(itemLimit); const sliceEntriesUpToItemLimit = R.slice(0, itemLimit); return R.when(entryShouldBeSliced, sliceEntriesUpToItemLimit)(entry); }