Switch to yarn
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npm run check
|
||||
npm run lint
|
||||
|
||||
Generated
-8531
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -14,10 +14,10 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node build.js",
|
||||
"pub": "npm i && npm run check && node build.js && npm publish",
|
||||
"check:ts": "tsc --noEmit --esModuleInterop --strict src/**/*",
|
||||
"check:es": "eslint src/*",
|
||||
"check": "run-p check:*"
|
||||
"pub": "npm i && npm run lint && node build.js && npm publish",
|
||||
"lint:ts": "tsc --noEmit --esModuleInterop --strict src/**/*",
|
||||
"lint:es": "eslint src/*",
|
||||
"lint": "run-p lint:*"
|
||||
},
|
||||
"keywords": [
|
||||
"nostr"
|
||||
|
||||
+3
-3
@@ -4,11 +4,11 @@ export class Relay {
|
||||
constructor(socket) {
|
||||
this.socket = socket
|
||||
this.bus = new EventBus()
|
||||
this.listeners = sockets.map(socket => {
|
||||
return socket.bus.addListener('message', (url, [verb, ...payload]) => {
|
||||
this.listeners = [
|
||||
socket.bus.addListener('message', (url, [verb, ...payload]) => {
|
||||
this.bus.emit(verb, url, ...payload)
|
||||
})
|
||||
})
|
||||
]
|
||||
}
|
||||
get sockets() {
|
||||
return [this.socket]
|
||||
|
||||
+21
-25
@@ -27,34 +27,30 @@ export class Socket {
|
||||
this.queue = []
|
||||
this.bus = new EventBus()
|
||||
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 = () => {
|
||||
this.error = undefined
|
||||
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')
|
||||
if (!this.timeout) {
|
||||
this.handleMessagesAsync()
|
||||
}
|
||||
}
|
||||
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() {
|
||||
if ([Socket.STATUS.NEW, Socket.STATUS.CLOSED].includes(this.status)) {
|
||||
if (this.ws) {
|
||||
|
||||
Reference in New Issue
Block a user