From 58431f9b6156dbe80e8d27b1f11d6df766537bba Mon Sep 17 00:00:00 2001 From: Noritaka Kobayashi Date: Sun, 1 Jun 2025 20:38:11 +0900 Subject: [PATCH] refactor: change if in else to else if --- copy-both.js | 8 +++----- copy-from.js | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/copy-both.js b/copy-both.js index 7f3bd0f..fdd459b 100644 --- a/copy-both.js +++ b/copy-both.js @@ -218,12 +218,10 @@ class CopyStreamQuery extends Duplex { if (callback) { if (ok) { callback() + } else if (this.chunks.length) { + this.connection.stream.once('drain', this.flush.bind(this, callback)) } else { - if (this.chunks.length) { - this.connection.stream.once('drain', this.flush.bind(this, callback)) - } else { - this.connection.stream.once('drain', callback) - } + this.connection.stream.once('drain', callback) } } } diff --git a/copy-from.js b/copy-from.js index 2e4c3be..d548d3f 100644 --- a/copy-from.js +++ b/copy-from.js @@ -103,12 +103,10 @@ class CopyStreamQuery extends Writable { if (callback) { if (ok) { callback() + } else if (this.chunks.length) { + this.connection.stream.once('drain', this.flush.bind(this, callback)) } else { - if (this.chunks.length) { - this.connection.stream.once('drain', this.flush.bind(this, callback)) - } else { - this.connection.stream.once('drain', callback) - } + this.connection.stream.once('drain', callback) } } }