|
- import zipWith from "lodash/zipWith";
-
- export const roundToNearestQuarter = (n: number): number => {
- return Math.round(n / 0.25) * 0.25;
- };
-
- export const distributeQuarters = (hours: number, parts: number): number[] => {
- if (!parts) return [];
-
- const numQuarters = hours * 4;
- const equalParts = Math.floor(numQuarters / parts);
- const remainders = Array(numQuarters % parts).fill(1);
-
- return zipWith(
- Array(parts).fill(equalParts),
- remainders,
- (a, b) => a + (b || 0),
- ).map((quarters) => quarters / 4);
- };
|