Fix sortBy to work with more data types, add kind 10014
This commit is contained in:
@@ -31,6 +31,6 @@
|
||||
"typescript": "~5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@welshman/util": "0.0.14"
|
||||
"@welshman/util": "0.0.15"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/lib",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of utilities.",
|
||||
|
||||
@@ -209,8 +209,13 @@ export const uniqBy = <T>(f: (x: T) => any, xs: T[]) => {
|
||||
|
||||
export const sort = <T>(xs: T[]) => [...xs].sort()
|
||||
|
||||
export const sortBy = <T>(f: (x: T) => number, xs: T[]) =>
|
||||
[...xs].sort((a: T, b: T) => f(a) - f(b))
|
||||
export const sortBy = <T>(f: (x: T) => any, xs: T[]) =>
|
||||
[...xs].sort((a: T, b: T) => {
|
||||
const x = f(a)
|
||||
const y = f(b)
|
||||
|
||||
return x < y ? -1 : x > y ? 1 : 0
|
||||
})
|
||||
|
||||
export const groupBy = <T, K>(f: (x: T) => K, xs: T[]) => {
|
||||
const r = new Map<K, T[]>()
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
"typescript": "~5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@welshman/lib": "0.0.9",
|
||||
"@welshman/util": "0.0.14",
|
||||
"@welshman/lib": "0.0.10",
|
||||
"@welshman/util": "0.0.15",
|
||||
"isomorphic-ws": "^5.0.0",
|
||||
"ws": "^8.16.0"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/util",
|
||||
"version": "0.0.14",
|
||||
"version": "0.0.15",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of nostr-related utilities.",
|
||||
@@ -31,7 +31,7 @@
|
||||
"typescript": "~5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@welshman/lib": "0.0.9",
|
||||
"@welshman/lib": "0.0.10",
|
||||
"nostr-tools": "^2.3.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ export const CHANNELS = 10005
|
||||
export const BLOCKED_RELAYS = 10006
|
||||
export const SEARCH_RELAYS = 10007
|
||||
export const GROUPS = 10009
|
||||
export const FEEDS = 10014
|
||||
export const TOPICS = 10015
|
||||
export const EMOJIS = 10030
|
||||
export const DM_INBOX_RELAYS = 10050
|
||||
|
||||
Reference in New Issue
Block a user