Break down relay utils, replace removeNil with removeUndefined

This commit is contained in:
Jon Staab
2025-11-11 14:05:30 -08:00
parent 4c1c138329
commit e582d46afd
8 changed files with 81 additions and 42 deletions
+12 -4
View File
@@ -1,5 +1,13 @@
import {derived} from "svelte/store"
import {sortBy, identity, ensurePlural, removeNil, batch, partition, first} from "@welshman/lib"
import {
sortBy,
identity,
ensurePlural,
removeUndefined,
batch,
partition,
first,
} from "@welshman/lib"
import {matchFilters, getIdAndAddress, getIdFilters, Filter, TrustedEvent} from "@welshman/util"
import {Repository} from "@welshman/net"
import {custom} from "./custom.js"
@@ -34,7 +42,7 @@ export const deriveEventsMapped = <T>(
if (deferred.has(event.id)) {
deferred.delete(event.id)
for (const item of removeNil(ensurePlural(items))) {
for (const item of removeUndefined(ensurePlural(items))) {
data.push(item)
}
@@ -53,7 +61,7 @@ export const deriveEventsMapped = <T>(
if (items instanceof Promise) {
defer(event, items)
} else {
for (const item of removeNil(ensurePlural(items))) {
for (const item of removeUndefined(ensurePlural(items))) {
data.push(item)
}
}
@@ -89,7 +97,7 @@ export const deriveEventsMapped = <T>(
} else if (items) {
dirty = true
for (const item of removeNil(ensurePlural(items))) {
for (const item of removeUndefined(ensurePlural(items))) {
data.push(item as T)
}
}