UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

28 lines (27 loc) 743 B
function findInsertPositionInArray(sortedArray, value, compareFn) { let left = 0; let right = sortedArray.length; while (left < right) { const mid = Math.floor((left + right) / 2); const comparison = compareFn(sortedArray[mid], value); if (comparison < 0) { left = mid + 1; } else { right = mid; } } return left; } function deleteInSortedArray(sortedArray, value, compareFn) { const idx = findInsertPositionInArray(sortedArray, value, compareFn); if (idx < sortedArray.length && compareFn(sortedArray[idx], value) === 0) { sortedArray.splice(idx, 1); return true; } return false; } export { deleteInSortedArray, findInsertPositionInArray }; //# sourceMappingURL=array-utils.js.map