Switch to yarn

This commit is contained in:
Jonathan Staab
2023-07-07 16:34:44 -07:00
parent b74f2e8e3d
commit 46470aabe4
6 changed files with 2672 additions and 8564 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
npm run check npm run lint
-8531
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -14,10 +14,10 @@
}, },
"scripts": { "scripts": {
"build": "node build.js", "build": "node build.js",
"pub": "npm i && npm run check && node build.js && npm publish", "pub": "npm i && npm run lint && node build.js && npm publish",
"check:ts": "tsc --noEmit --esModuleInterop --strict src/**/*", "lint:ts": "tsc --noEmit --esModuleInterop --strict src/**/*",
"check:es": "eslint src/*", "lint:es": "eslint src/*",
"check": "run-p check:*" "lint": "run-p lint:*"
}, },
"keywords": [ "keywords": [
"nostr" "nostr"
+3 -3
View File
@@ -4,11 +4,11 @@ export class Relay {
constructor(socket) { constructor(socket) {
this.socket = socket this.socket = socket
this.bus = new EventBus() this.bus = new EventBus()
this.listeners = sockets.map(socket => { this.listeners = [
return socket.bus.addListener('message', (url, [verb, ...payload]) => { socket.bus.addListener('message', (url, [verb, ...payload]) => {
this.bus.emit(verb, url, ...payload) this.bus.emit(verb, url, ...payload)
}) })
}) ]
} }
get sockets() { get sockets() {
return [this.socket] return [this.socket]
+21 -25
View File
@@ -27,34 +27,30 @@ export class Socket {
this.queue = [] this.queue = []
this.bus = new EventBus() this.bus = new EventBus()
this.status = Socket.STATUS.NEW this.status = Socket.STATUS.NEW
}
onOpen() {
this.error = undefined
this.status = Socket.STATUS.READY
this.ready.resolve()
this.bus.emit('open')
}
onMessage(event) {
this.queue.push(event.data as string)
this._onOpen = () => { if (!this.timeout) {
this.error = undefined this.handleMessagesAsync()
this.status = Socket.STATUS.READY
this.ready.resolve()
this.bus.emit('open')
}
this._onMessage = event => {
this.queue.push(event.data as string)
if (!this.timeout) {
this.handleMessagesAsync()
}
}
this._onError = (error: Error) => {
this.error = error
this.bus.emit('error', error)
}
this._onClose = () => {
this.disconnect()
this.ready.reject()
this.status = Socket.STATUS.CLOSED
this.bus.emit('close')
} }
} }
onError(error: Error) {
this.error = error
this.bus.emit('error', error)
}
onClose() {
this.disconnect()
this.ready.reject()
this.status = Socket.STATUS.CLOSED
this.bus.emit('close')
}
async connect() { async connect() {
if ([Socket.STATUS.NEW, Socket.STATUS.CLOSED].includes(this.status)) { if ([Socket.STATUS.NEW, Socket.STATUS.CLOSED].includes(this.status)) {
if (this.ws) { if (this.ws) {
+2643
View File
File diff suppressed because it is too large Load Diff