From e7afd3ec769060ec8668467e739a76a3083c500b Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 4 Nov 2019 19:32:44 -0800 Subject: [PATCH] respond to comments --- src/api.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api.ts b/src/api.ts index d2057cac..8197d0c4 100644 --- a/src/api.ts +++ b/src/api.ts @@ -140,13 +140,14 @@ class RippleAPI extends EventEmitter { this.emit('connected') }) this.connection.on('disconnected', code => { + let finalCode = code; // This is a backwards-compatible fix for this change in the ws library: // https://github.com/websockets/ws/issues/1257 // TODO: Remove in next major, breaking version - if (code === 1005) { - code = 1000; + if (finalCode === 1005) { + finalCode = 1000; } - this.emit('disconnected', code) + this.emit('disconnected', finalCode) }) } else { // use null object pattern to provide better error message if user