Fix sortBy to work with more data types, add kind 10014

This commit is contained in:
Jon Staab
2024-06-20 10:19:32 -07:00
parent 760e0a99b4
commit 22a5fb58b4
7 changed files with 22 additions and 16 deletions
+8 -8
View File
@@ -3087,10 +3087,10 @@
}, },
"packages/feeds": { "packages/feeds": {
"name": "@welshman/feeds", "name": "@welshman/feeds",
"version": "0.0.10", "version": "0.0.12",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/util": "0.0.14" "@welshman/util": "0.0.15"
}, },
"devDependencies": { "devDependencies": {
"gts": "^5.0.1", "gts": "^5.0.1",
@@ -3100,7 +3100,7 @@
}, },
"packages/lib": { "packages/lib": {
"name": "@welshman/lib", "name": "@welshman/lib",
"version": "0.0.9", "version": "0.0.10",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@scure/base": "^1.1.6", "@scure/base": "^1.1.6",
@@ -3124,11 +3124,11 @@
}, },
"packages/net": { "packages/net": {
"name": "@welshman/net", "name": "@welshman/net",
"version": "0.0.12", "version": "0.0.13",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.9", "@welshman/lib": "0.0.10",
"@welshman/util": "0.0.14", "@welshman/util": "0.0.15",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"ws": "^8.16.0" "ws": "^8.16.0"
}, },
@@ -3140,10 +3140,10 @@
}, },
"packages/util": { "packages/util": {
"name": "@welshman/util", "name": "@welshman/util",
"version": "0.0.14", "version": "0.0.15",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.9", "@welshman/lib": "0.0.10",
"nostr-tools": "^2.3.2" "nostr-tools": "^2.3.2"
}, },
"devDependencies": { "devDependencies": {
+1 -1
View File
@@ -31,6 +31,6 @@
"typescript": "~5.1.6" "typescript": "~5.1.6"
}, },
"dependencies": { "dependencies": {
"@welshman/util": "0.0.14" "@welshman/util": "0.0.15"
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/lib", "name": "@welshman/lib",
"version": "0.0.9", "version": "0.0.10",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of utilities.", "description": "A collection of utilities.",
+7 -2
View File
@@ -209,8 +209,13 @@ export const uniqBy = <T>(f: (x: T) => any, xs: T[]) => {
export const sort = <T>(xs: T[]) => [...xs].sort() export const sort = <T>(xs: T[]) => [...xs].sort()
export const sortBy = <T>(f: (x: T) => number, xs: T[]) => export const sortBy = <T>(f: (x: T) => any, xs: T[]) =>
[...xs].sort((a: T, b: T) => f(a) - f(b)) [...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[]) => { export const groupBy = <T, K>(f: (x: T) => K, xs: T[]) => {
const r = new Map<K, T[]>() const r = new Map<K, T[]>()
+2 -2
View File
@@ -31,8 +31,8 @@
"typescript": "~5.1.6" "typescript": "~5.1.6"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.9", "@welshman/lib": "0.0.10",
"@welshman/util": "0.0.14", "@welshman/util": "0.0.15",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"ws": "^8.16.0" "ws": "^8.16.0"
} }
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/util", "name": "@welshman/util",
"version": "0.0.14", "version": "0.0.15",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of nostr-related utilities.", "description": "A collection of nostr-related utilities.",
@@ -31,7 +31,7 @@
"typescript": "~5.1.6" "typescript": "~5.1.6"
}, },
"dependencies": { "dependencies": {
"@welshman/lib": "0.0.9", "@welshman/lib": "0.0.10",
"nostr-tools": "^2.3.2" "nostr-tools": "^2.3.2"
} }
} }
+1
View File
@@ -98,6 +98,7 @@ export const CHANNELS = 10005
export const BLOCKED_RELAYS = 10006 export const BLOCKED_RELAYS = 10006
export const SEARCH_RELAYS = 10007 export const SEARCH_RELAYS = 10007
export const GROUPS = 10009 export const GROUPS = 10009
export const FEEDS = 10014
export const TOPICS = 10015 export const TOPICS = 10015
export const EMOJIS = 10030 export const EMOJIS = 10030
export const DM_INBOX_RELAYS = 10050 export const DM_INBOX_RELAYS = 10050