58ca4e68db
- Go backend API with full CRUD for all modules (CRM, Sales, Finance, HR, Legal, Marketing, Support, Purchase, Inventory, Projects, Automation, Analytics) - Rust analytics service with parallel report generation - C runtime with POSIX shared memory IPC - PostgreSQL schema with 30+ tables, full migrations - Redis cache, sessions, pub/sub - Kafka event streaming with Zookeeper - WebSocket hub for real-time updates - Automation engine with cron jobs, workflows, event triggers - JWT authentication, multi-tenant from start - Docker Compose with all services - Nginx reverse proxy with rate limiting - Integration tests passing - Feature gap analysis against Fortnox/Odoo/Visma Refs: BOC-001
36 lines
953 B
JavaScript
36 lines
953 B
JavaScript
/**
|
|
* ...something resembling a binary search, to find the lowest line within the range.
|
|
* And then you could break as soon as the line is longer than the range...
|
|
*/
|
|
module.exports.sliceRange = (lines, startCol, endCol, inclusive = false) => {
|
|
let start = 0
|
|
let end = lines.length
|
|
|
|
if (inclusive) {
|
|
// I consider this a temporary solution until I find an alternaive way to fix the "off by one issue"
|
|
--startCol
|
|
}
|
|
|
|
while (start < end) {
|
|
let mid = (start + end) >> 1
|
|
if (startCol >= lines[mid].endCol) {
|
|
start = mid + 1
|
|
} else if (endCol < lines[mid].startCol) {
|
|
end = mid - 1
|
|
} else {
|
|
end = mid
|
|
while (mid >= 0 && startCol < lines[mid].endCol && endCol >= lines[mid].startCol) {
|
|
--mid
|
|
}
|
|
start = mid + 1
|
|
break
|
|
}
|
|
}
|
|
|
|
while (end < lines.length && startCol < lines[end].endCol && endCol >= lines[end].startCol) {
|
|
++end
|
|
}
|
|
|
|
return lines.slice(start, end)
|
|
}
|