Skip to content

Commit 261bae1

Browse files
committed
Use switch-style of arg validation to fix lint errors
1 parent 9468a81 commit 261bae1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/pool.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,20 @@ function getConnection(a1, a2) {
136136
var timeoutHandle;
137137
var timerIdx;
138138
var poolMax;
139-
var getConnectionCb = arguments[arguments.length - 1];
139+
var getConnectionCb;
140140
var options = {};
141141

142142
nodbUtil.assert(arguments.length >= 1 && arguments.length <= 2, 'NJS-009');
143+
switch (arguments.length) {
144+
case 1:
145+
getConnectionCb = a1;
146+
break;
147+
case 2:
148+
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-006', 1);
149+
options = a1;
150+
getConnectionCb = a2;
151+
break;
152+
}
143153
nodbUtil.assert(typeof getConnectionCb === 'function', 'NJS-006', arguments.length);
144154

145155
if (self.status === self._oracledb.POOL_STATUS_DRAINING) { // closing soon
@@ -150,12 +160,6 @@ function getConnection(a1, a2) {
150160
return;
151161
}
152162

153-
// Optional JSON parameter
154-
if (arguments.length > 1 ) {
155-
options = arguments[0];
156-
nodbUtil.assert(nodbUtil.isObject(options), 'NJS-006', 1 );
157-
}
158-
159163
if (self._enableStats) {
160164
self._totalConnectionRequests += 1;
161165
}

0 commit comments

Comments
 (0)