From ce50a229e9dbf2ed85f554bc64bdb09a512ed10c Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Thu, 1 Aug 2024 14:23:33 +0200 Subject: [PATCH 1/2] Use `Array.isArray` instead of `util.isArray` --- lib/protocol/MessageBuffer.js | 2 +- lib/protocol/Statement.js | 4 ++-- lib/protocol/part/AbstractOptions.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/protocol/MessageBuffer.js b/lib/protocol/MessageBuffer.js index 51a79e9..84f2603 100644 --- a/lib/protocol/MessageBuffer.js +++ b/lib/protocol/MessageBuffer.js @@ -48,7 +48,7 @@ MessageBuffer.prototype.push = function push(chunk) { }; MessageBuffer.prototype.getData = function getData() { - if (util.isArray(this.data)) { + if (Array.isArray(this.data)) { return Buffer.concat(this.data, this.length); } return this.data; diff --git a/lib/protocol/Statement.js b/lib/protocol/Statement.js index d244074..b16e7d4 100644 --- a/lib/protocol/Statement.js +++ b/lib/protocol/Statement.js @@ -71,7 +71,7 @@ Statement.prototype.drop = function drop(cb) { }; Statement.prototype.getParameterName = function getParameterName(i) { - if (util.isArray(this.parameterMetadata) && i < this.parameterMetadata.length) { + if (Array.isArray(this.parameterMetadata) && i < this.parameterMetadata.length) { return this.parameterMetadata[i].name; } }; @@ -84,7 +84,7 @@ Statement.prototype.handle = function handle(err, reply, cb) { this.id = reply.statementId; this.functionCode = reply.functionCode; - if (util.isArray(reply.resultSets) && reply.resultSets.length) { + if (Array.isArray(reply.resultSets) && reply.resultSets.length) { this.resultSetMetadata = reply.resultSets[0].metadata; } this.parameterMetadata = reply.parameterMetadata; diff --git a/lib/protocol/part/AbstractOptions.js b/lib/protocol/part/AbstractOptions.js index c0178e5..016afc5 100644 --- a/lib/protocol/part/AbstractOptions.js +++ b/lib/protocol/part/AbstractOptions.js @@ -40,7 +40,7 @@ AbstractOptions.prototype.getOptions = function getOptions() { AbstractOptions.prototype.setOptions = function setOptions(options) { var self = this; - if (!util.isArray(options)) { + if (!Array.isArray(options)) { return; } From eb0db024645890dd17860cddb28d151231998ada Mon Sep 17 00:00:00 2001 From: Steffen Waldmann Date: Thu, 1 Aug 2024 14:34:04 +0200 Subject: [PATCH 2/2] More --- lib/protocol/Connection.js | 2 +- lib/protocol/Stringifier.js | 2 +- lib/protocol/data/Fields.js | 5 ++--- lib/protocol/reply/Segment.js | 2 +- lib/util/index.js | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/protocol/Connection.js b/lib/protocol/Connection.js index 7cbabdd..447c01f 100644 --- a/lib/protocol/Connection.js +++ b/lib/protocol/Connection.js @@ -481,7 +481,7 @@ Connection.prototype.connect = function connect(options, cb) { if (err) { return cb(err); } - if (util.isArray(reply.connectOptions)) { + if (Array.isArray(reply.connectOptions)) { self.connectOptions.setOptions(reply.connectOptions); } manager.finalize(reply.authentication); diff --git a/lib/protocol/Stringifier.js b/lib/protocol/Stringifier.js index 1b5a49b..e939269 100644 --- a/lib/protocol/Stringifier.js +++ b/lib/protocol/Stringifier.js @@ -38,7 +38,7 @@ function Stringifier(options) { } Stringifier.prototype._transform = function _transform(thing, encoding, done) { - if (util.isArray(thing) && thing.length) { + if (Array.isArray(thing) && thing.length) { this.push(this.transformRows(thing)); } else { this.push(this.transformRow(thing)); diff --git a/lib/protocol/data/Fields.js b/lib/protocol/data/Fields.js index 84b4c8d..2bcae62 100644 --- a/lib/protocol/data/Fields.js +++ b/lib/protocol/data/Fields.js @@ -14,7 +14,6 @@ 'use strict'; const common = require('../../protocol/common'); -var util = require('../../util'); exports.read = read; exports.write = write; @@ -81,7 +80,7 @@ function write(part, fields) { field = fields[i]; if (Buffer.isBuffer(field)) { data = field; - } else if (util.isArray(field)) { + } else if (Array.isArray(field)) { data = write({}, field).buffer; } else { data = new Buffer(field, 'ascii'); @@ -133,7 +132,7 @@ function getArgumentCount(fields) { function getByteLengthOfField(field) { if (Buffer.isBuffer(field)) { return field.length; - } else if (util.isArray(field)) { + } else if (Array.isArray(field)) { return getByteLength(field); } return Buffer.byteLength(field, 'ascii'); diff --git a/lib/protocol/reply/Segment.js b/lib/protocol/reply/Segment.js index 7aecd1c..4b81704 100644 --- a/lib/protocol/reply/Segment.js +++ b/lib/protocol/reply/Segment.js @@ -170,7 +170,7 @@ Reply.prototype.add = function add(part) { this.addResultSetFragment(name, value); } else if (util.isUndefined(this[name])) { this[name] = value; - } else if (util.isArray(this[name])) { + } else if (Array.isArray(this[name])) { this[name].push(value); } else { var existingValue = this[name]; diff --git a/lib/util/index.js b/lib/util/index.js index b534596..bdcda91 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -216,7 +216,7 @@ function proxyEvents(source, target, events) { exports.proxyEvents = proxyEvents; function createReadStream(ds, events, options) { - if (!util.isArray(events)) { + if (!Array.isArray(events)) { options = events; events = ['error', 'close']; }