Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 37x 4x 29x 29x 29x 832x 4x 33x 36x 3x 2x 5x 2x 2x 2x 3x 2296x 2516x 992x 3x 3x 3x 36x 15x 36x 36x | import type { QueryParams } from '../interfaces'
export const pendingDeleteMap = new Map<string, Set<string>>()
export function addPendingDelete(entityPath: string, id: string): void {
const set = pendingDeleteMap.get(entityPath) ?? new Set()
set.add(id)
pendingDeleteMap.set(entityPath, set)
}
export function removePendingDelete(entityPath: string, id: string): void {
pendingDeleteMap.get(entityPath)?.delete(id)
}
export function getPendingDeletes(entityPath: string): Set<string> {
return pendingDeleteMap.get(entityPath) ?? new Set()
}
export function isMarkedDeleted(entityPath: string, id: string): boolean {
return pendingDeleteMap.get(entityPath)?.has(id) ?? false
}
export function populatePendingDeletes(
entries: Array<{ entityPath: string; id: string }>,
): void {
for (const { entityPath, id } of entries) {
addPendingDelete(entityPath, id)
}
}
export function getAllPendingDeleteEntries(): Array<{
entityPath: string
id: string
}> {
const entries: Array<{ entityPath: string; id: string }> = []
for (const [entityPath, ids] of pendingDeleteMap) {
for (const id of ids) {
entries.push({ entityPath, id })
}
}
return entries
}
export function purgePendingDeletes(entityPath: string): Set<string> {
const set = pendingDeleteMap.get(entityPath) ?? new Set()
pendingDeleteMap.delete(entityPath)
return set
}
export function normalizeFilters<T extends QueryParams>(
filters: T,
): Partial<Record<string, string | number | boolean>> {
const entries = Object.entries(filters).filter(
([, v]) => v !== undefined && v !== '',
)
entries.sort(([a], [b]) => a.localeCompare(b))
return Object.fromEntries(entries)
} |