diff --git a/packages/lib/src/Tools.ts b/packages/lib/src/Tools.ts index 6dc0fd3..696f6d9 100644 --- a/packages/lib/src/Tools.ts +++ b/packages/lib/src/Tools.ts @@ -22,6 +22,10 @@ export type Override = Omit & R export type MakeOptional = Override>> +export type MakeNonOptional = { + [K in keyof T]-?: T[K] +} + // ---------------------------------------------------------------------------- // Basic functional programming utilities // ---------------------------------------------------------------------------- @@ -426,7 +430,7 @@ export const concat = (...xs: T[][]) => xs.flatMap(x => (x === undefined ? [] * @param xs - Array to append to * @returns New array with element appended */ -export const append = (x: T, xs: T[]) => concat(xs, [x]) +export const append = (x: T, xs: Iterable) => concat(Array.from(xs), [x]) /** * Creates union of two arrays @@ -434,7 +438,7 @@ export const append = (x: T, xs: T[]) => concat(xs, [x]) * @param b - Second array * @returns Array containing unique elements from both arrays */ -export const union = (a: T[], b: T[]) => uniq([...a, ...b]) +export const union = (a: Iterable, b: Iterable) => uniq([...a, ...b]) /** * Returns elements common to both arrays @@ -442,10 +446,10 @@ export const union = (a: T[], b: T[]) => uniq([...a, ...b]) * @param b - Second array * @returns Array of elements present in both inputs */ -export const intersection = (a: T[], b: T[]) => { +export const intersection = (a: Iterable, b: Iterable) => { const s = new Set(b) - return a.filter(x => s.has(x)) + return Array.from(a).filter(x => s.has(x)) } /** @@ -454,10 +458,10 @@ export const intersection = (a: T[], b: T[]) => { * @param b - Array of elements to exclude * @returns Array containing elements unique to first array */ -export const difference = (a: T[], b: T[]) => { +export const difference = (a: Iterable, b: Iterable) => { const s = new Set(b) - return a.filter(x => !s.has(x)) + return Array.from(a).filter(x => !s.has(x)) } /** diff --git a/packages/util/src/Events.ts b/packages/util/src/Events.ts index 3731f93..d91af81 100644 --- a/packages/util/src/Events.ts +++ b/packages/util/src/Events.ts @@ -12,6 +12,8 @@ import { isParameterizedReplaceableKind, } from "./Kinds.js" +export {verifiedSymbol} + export type EventContent = { tags: string[][] content: string