Add without
This commit is contained in:
@@ -91,6 +91,8 @@ export const difference = <T>(a: T[], b: T[]) => {
|
|||||||
|
|
||||||
export const remove = <T>(a: T, b: T[]) => b.filter(x => x !== a)
|
export const remove = <T>(a: T, b: T[]) => b.filter(x => x !== a)
|
||||||
|
|
||||||
|
export const without = <T>(a: T[], b: T[]) => b.filter(x => !a.includes(x))
|
||||||
|
|
||||||
export const clamp = ([min, max]: [number, number], n: number) => Math.min(max, Math.max(min, n))
|
export const clamp = ([min, max]: [number, number], n: number) => Math.min(max, Math.max(min, n))
|
||||||
|
|
||||||
export const tryCatch = async <T>(f: () => Promise<T | void> | T | void, onError?: (e: Error) => void): Promise<T | void> => {
|
export const tryCatch = async <T>(f: () => Promise<T | void> | T | void, onError?: (e: Error) => void): Promise<T | void> => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {Event} from 'nostr-tools'
|
|||||||
import {matchFilter as nostrToolsMatchFilter} from 'nostr-tools'
|
import {matchFilter as nostrToolsMatchFilter} from 'nostr-tools'
|
||||||
import {prop, avg, hash, groupBy, randomId, uniq} from '@welshman/lib'
|
import {prop, avg, hash, groupBy, randomId, uniq} from '@welshman/lib'
|
||||||
import type {HashedEvent, TrustedEvent} from './Events'
|
import type {HashedEvent, TrustedEvent} from './Events'
|
||||||
import {isReplaceableKind, isPlainReplaceableKind} from './Kinds'
|
import {isReplaceableKind} from './Kinds'
|
||||||
import {Address, getAddress} from './Address'
|
import {Address, getAddress} from './Address'
|
||||||
|
|
||||||
export const EPOCH = 1609459200
|
export const EPOCH = 1609459200
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ export class Router {
|
|||||||
EventAncestors = (event: TrustedEvent, type: "mentions" | "replies" | "roots") => {
|
EventAncestors = (event: TrustedEvent, type: "mentions" | "replies" | "roots") => {
|
||||||
const tags = Tags.fromEvent(event)
|
const tags = Tags.fromEvent(event)
|
||||||
const ancestors = tags.ancestors()[type]
|
const ancestors = tags.ancestors()[type]
|
||||||
const pubkeys = tags.whereKey("p").values().valueOf()
|
const pubkeys = tags.values("p").valueOf()
|
||||||
const communities = tags.communities().values().valueOf()
|
const communities = tags.communities().values().valueOf()
|
||||||
const groups = tags.groups().values().valueOf()
|
const groups = tags.groups().values().valueOf()
|
||||||
const relays = uniq([
|
const relays = uniq([
|
||||||
|
|||||||
Reference in New Issue
Block a user