diff --git a/archived/aria2_0.7.0.js b/archived/aria2_0.7.0.js index b450184..ce55f19 100644 --- a/archived/aria2_0.7.0.js +++ b/archived/aria2_0.7.0.js @@ -68,13 +68,13 @@ class Aria2 { this.socket?.then( (ws) => ws.close() ); } set onmessage (callback) { - this.jsonrpc.onmessage = callback; + this.jsonrpc.onmessage = typeof callback === 'function' ? callback : null; } get onmessage () { return typeof this.jsonrpc.onmessage === 'function' ? this.jsonrpc.onmessage : null; } set onclose (callback) { - this.jsonrpc.onclose = callback; + this.jsonrpc.onclose = typeof callback === 'function' ? callback : null; } get onclose () { return typeof this.jsonrpc.onclose === 'function' ? this.jsonrpc.onclose : null; diff --git a/aria2.js b/aria2.js index b450184..ce55f19 100644 --- a/aria2.js +++ b/aria2.js @@ -68,13 +68,13 @@ class Aria2 { this.socket?.then( (ws) => ws.close() ); } set onmessage (callback) { - this.jsonrpc.onmessage = callback; + this.jsonrpc.onmessage = typeof callback === 'function' ? callback : null; } get onmessage () { return typeof this.jsonrpc.onmessage === 'function' ? this.jsonrpc.onmessage : null; } set onclose (callback) { - this.jsonrpc.onclose = callback; + this.jsonrpc.onclose = typeof callback === 'function' ? callback : null; } get onclose () { return typeof this.jsonrpc.onclose === 'function' ? this.jsonrpc.onclose : null; diff --git a/aria2ws.js b/aria2ws.js index 51e77cc..6003e21 100644 --- a/aria2ws.js +++ b/aria2ws.js @@ -28,13 +28,13 @@ class Aria2WebSocket { this.socket.then( (ws) => ws.close() ); } set onmessage (callback) { - this._onmessage = callback; + this._onmessage = typeof callback === 'function' ? callback : null; } get onmessage () { return typeof this._onmessage === 'function' ? this._onmessage : null; } set onclose (callback) { - this._onclose = callback; + this._onclose = typeof callback === 'function' ? callback : null; } get onclose () { return typeof this._onclose === 'function' ? this._onclose : null;