summaryrefslogtreecommitdiff
path: root/lib/_http_agent.js
diff options
context:
space:
mode:
authorDenys Otrishko <shishugi@gmail.com>2020-06-26 13:14:48 +0300
committerJames M Snell <jasnell@gmail.com>2020-08-17 11:50:46 -0700
commit6726246dbb83e3251f080fc4729154d492f7e340 (patch)
treeacb72cb1e8a5f4cdbdc1f77d0fec2f565d001df7 /lib/_http_agent.js
parentc62cf1d9c50aa4d152f28f61df86a6faafa45093 (diff)
downloadnode-new-6726246dbb83e3251f080fc4729154d492f7e340.tar.gz
lib: allow to validate enums with validateOneOf
PR-URL: https://github.com/nodejs/node/pull/34070 Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/_http_agent.js')
-rw-r--r--lib/_http_agent.js7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/_http_agent.js b/lib/_http_agent.js
index c4430e86ec..fc20260baf 100644
--- a/lib/_http_agent.js
+++ b/lib/_http_agent.js
@@ -39,12 +39,11 @@ const { async_id_symbol } = require('internal/async_hooks').symbols;
const {
codes: {
ERR_INVALID_ARG_TYPE,
- ERR_INVALID_OPT_VALUE,
ERR_OUT_OF_RANGE,
},
} = require('internal/errors');
const { once } = require('internal/util');
-const { validateNumber } = require('internal/validators');
+const { validateNumber, validateOneOf } = require('internal/validators');
const kOnKeylog = Symbol('onkeylog');
const kRequestOptions = Symbol('requestOptions');
@@ -99,9 +98,7 @@ function Agent(options) {
this.maxTotalSockets = this.options.maxTotalSockets;
this.totalSocketCount = 0;
- if (this.scheduling !== 'fifo' && this.scheduling !== 'lifo') {
- throw new ERR_INVALID_OPT_VALUE('scheduling', this.scheduling);
- }
+ validateOneOf(this.scheduling, 'scheduling', ['fifo', 'lifo'], true);
if (this.maxTotalSockets !== undefined) {
validateNumber(this.maxTotalSockets, 'maxTotalSockets');