UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

44 lines (43 loc) 1.38 kB
/** * DevExtreme (esm/__internal/scheduler/view_model/generate_view_model/steps/maybe_split.js) * Version: 25.2.5 * Build date: Fri Feb 20 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { splitByCondition } from "./add_collector/split_by_condition"; const mergeByStartDate = (a, b) => { const result = []; let i = 0; let j = 0; while (i < a.length && j < b.length) { if (a[i].startDateUTC <= b[j].startDateUTC) { result.push(a[i]); i += 1 } else { result.push(b[j]); j += 1 } } while (i < a.length) { result.push(a[i]); i += 1 } while (j < b.length) { result.push(b[j]); j += 1 } return result }; export const maybeSplit = (entities, shouldSplit, callback) => { if (shouldSplit) { const [allDayEntities, regularEntities] = splitByCondition(entities, (entity => entity.isAllDayPanelOccupied)); const allDayPanel = callback(allDayEntities, "allDayPanel"); const regularPanel = callback(regularEntities, "regularPanel"); return mergeByStartDate(allDayPanel, regularPanel) } return callback(entities, "regularPanel") };