Skip to content

Commit

Permalink
discojs-core: drop node:url
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Feb 12, 2024
1 parent 9c0a34b commit 9f52c4d
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion discojs/discojs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"msgpack-lite": "0.1",
"simple-peer": "9",
"tslib": "2",
"url": "0.11",
"ws": "8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion discojs/discojs-core/src/client/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Set } from 'immutable'
import axios from 'axios'
import { Set } from 'immutable'

import { tf, Task, TrainingInformant, serialization, WeightsContainer } from '..'
import { NodeID } from './types'
Expand Down
2 changes: 0 additions & 2 deletions discojs/discojs-core/src/client/decentralized/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Map, Set } from 'immutable'
import * as nodeUrl from 'url'

import { TrainingInformant, WeightsContainer, serialization } from '../..'
import { Client, NodeID } from '..'
Expand Down Expand Up @@ -96,7 +95,6 @@ export class Base extends Client {
}

async connect (): Promise<void> {
const URL = typeof window !== 'undefined' ? window.URL : nodeUrl.URL
const serverURL = new URL('', this.url.href)
switch (this.url.protocol) {
case 'http:':
Expand Down
6 changes: 3 additions & 3 deletions discojs/discojs-core/src/client/event_connection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isomorphic, { WebSocket } from 'isomorphic-ws'
import WebSocket from 'isomorphic-ws'
import { EventEmitter } from 'events'
import { Peer } from './decentralized/peer'
import { NodeID } from './types'
Expand Down Expand Up @@ -109,7 +109,7 @@ export class WebSocketServer implements EventConnection {
const emitter: EventEmitter = new EventEmitter()
const server: WebSocketServer = new WebSocketServer(ws, emitter, validateReceived, validateSent)

ws.onmessage = (event: isomorphic.MessageEvent) => {
ws.onmessage = (event: WebSocket.MessageEvent) => {
if (!(event.data instanceof ArrayBuffer)) {
throw new Error('server did not send an ArrayBuffer')
}
Expand All @@ -125,7 +125,7 @@ export class WebSocketServer implements EventConnection {
}

return await new Promise((resolve, reject) => {
ws.onerror = (err: isomorphic.ErrorEvent) =>
ws.onerror = (err: WebSocket.ErrorEvent) =>
reject(new Error(`connecting server: ${err.message}`)) // eslint-disable-line @typescript-eslint/restrict-template-expressions
ws.onopen = () => resolve(server)
})
Expand Down
2 changes: 0 additions & 2 deletions discojs/discojs-core/src/client/federated/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as nodeUrl from 'url'
import { Map } from 'immutable'

import { serialization, informant, MetadataKey, MetadataValue, WeightsContainer, TrainingInformant } from '../..'
Expand Down Expand Up @@ -43,7 +42,6 @@ export class Base extends Client {
* for the task.
*/
async connect (): Promise<void> {
const URL = typeof window !== 'undefined' ? window.URL : nodeUrl.URL
const serverURL = new URL('', this.url.href)
switch (this.url.protocol) {
case 'http:':
Expand Down
2 changes: 1 addition & 1 deletion discojs/discojs-core/src/task/task_handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Map } from 'immutable'
import axios from 'axios'
import { Map } from 'immutable'

import { serialization, tf, WeightsContainer } from '..'
import { isTask, Task, TaskID } from './task'
Expand Down
1 change: 1 addition & 0 deletions discojs/discojs-web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"lib": ["DOM"],
"outDir": "dist",
"baseUrl": "src"
},
Expand Down
2 changes: 1 addition & 1 deletion discojs/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
// TODO ES6 disallow server's test
"target": "ES5",
"lib": ["ES5", "DOM"],
"lib": ["ES5"],

"strict": true,
"noEmitOnError": true,
Expand Down

0 comments on commit 9f52c4d

Please sign in to comment.