mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
refactor(editor): Move editor-ui and design-system to frontend dir (no-changelog) (#13564)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import type { Range } from './types';
|
||||
|
||||
/**
|
||||
* Return the ranges of a full range that are _not_ within the taken ranges,
|
||||
* assuming sorted taken ranges. e.g. `[0, 10]` and `[[2, 3], [7, 8]]`
|
||||
* return `[[0, 1], [4, 6], [9, 10]]`
|
||||
*/
|
||||
export function nonTakenRanges(fullRange: Range, takenRanges: Range[]) {
|
||||
const found = [];
|
||||
|
||||
const [fullStart, fullEnd] = fullRange;
|
||||
let i = fullStart;
|
||||
let curStart = fullStart;
|
||||
|
||||
takenRanges = [...takenRanges];
|
||||
|
||||
while (i < fullEnd) {
|
||||
if (takenRanges.length === 0) {
|
||||
found.push([curStart, fullEnd]);
|
||||
break;
|
||||
}
|
||||
|
||||
const [takenStart, takenEnd] = takenRanges[0];
|
||||
|
||||
if (i < takenStart) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (takenStart !== fullStart) {
|
||||
found.push([curStart, i - 1]);
|
||||
}
|
||||
|
||||
i = takenEnd + 1;
|
||||
curStart = takenEnd + 1;
|
||||
takenRanges.shift();
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
Reference in New Issue
Block a user