UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

21 lines (16 loc) 590 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; const countValues = (data, [from, to], min) => data.reduce(([selected, totalCount], curr, index) => { return [index + min >= from && index + min <= to ? selected + curr : selected, totalCount + curr]; }, [0, 0]); const calculateCountOf = (data, value, min) => { if (Array.isArray(value)) { return countValues(data, [value[0], value[value.length - 1]], min); } return countValues(data, [min, value], min); }; var _default = calculateCountOf; exports.default = _default;