GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: refactor to use validate function · nodejs/node@1cfa2e6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _http_client.js
    • _tls_wrap.js
    • async_hooks.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/_http_client.js‎

Copy file name to clipboardExpand all lines: lib/_http_client.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,10 @@ function ClientRequest(input, options, cb) {
223223
this.maxHeaderSize = maxHeaderSize;
224224

225225
const insecureHTTPParser = options.insecureHTTPParser;
226-
if (insecureHTTPParser !== undefined &&
227-
typeof insecureHTTPParser !== 'boolean') {
228-
throw new ERR_INVALID_ARG_TYPE(
229-
'options.insecureHTTPParser', 'boolean', insecureHTTPParser);
226+
if (insecureHTTPParser !== undefined) {
227+
validateBoolean(insecureHTTPParser, 'options.insecureHTTPParser');
230228
}
229+
231230
this.insecureHTTPParser = insecureHTTPParser;
232231

233232
if (options.joinDuplicateHeaders !== undefined) {
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+7-12Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,21 +1224,16 @@ function Server(options, listener) {
12241224

12251225
validateNumber(this[kHandshakeTimeout], 'options.handshakeTimeout');
12261226

1227-
if (this[kSNICallback] && typeof this[kSNICallback] !== 'function') {
1228-
throw new ERR_INVALID_ARG_TYPE(
1229-
'options.SNICallback', 'function', options.SNICallback);
1227+
if (this[kSNICallback]) {
1228+
validateFunction(this[kSNICallback], 'options.SNICallback');
12301229
}
12311230

1232-
if (this[kPskCallback] && typeof this[kPskCallback] !== 'function') {
1233-
throw new ERR_INVALID_ARG_TYPE(
1234-
'options.pskCallback', 'function', options.pskCallback);
1231+
if (this[kPskCallback]) {
1232+
validateFunction(this[kPskCallback], 'options.pskCallback');
12351233
}
1236-
if (this[kPskIdentityHint] && typeof this[kPskIdentityHint] !== 'string') {
1237-
throw new ERR_INVALID_ARG_TYPE(
1238-
'options.pskIdentityHint',
1239-
'string',
1240-
options.pskIdentityHint
1241-
);
1234+
1235+
if (this[kPskIdentityHint]) {
1236+
validateString(this[kPskIdentityHint], 'options.pskIdentityHint');
12421237
}
12431238

12441239
// constructor call
Collapse file

‎lib/async_hooks.js‎

Copy file name to clipboardExpand all lines: lib/async_hooks.js
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const {
1818
const {
1919
ERR_ASYNC_CALLBACK,
2020
ERR_ASYNC_TYPE,
21-
ERR_INVALID_ARG_TYPE,
2221
ERR_INVALID_ASYNC_ID
2322
} = require('internal/errors').codes;
2423
const { kEmptyObject } = require('internal/util');
@@ -280,10 +279,8 @@ class AsyncLocalStorage {
280279
validateObject(options, 'options');
281280

282281
const { onPropagate = null } = options;
283-
if (onPropagate !== null && typeof onPropagate !== 'function') {
284-
throw new ERR_INVALID_ARG_TYPE('options.onPropagate',
285-
'function',
286-
onPropagate);
282+
if (onPropagate !== null) {
283+
validateFunction(onPropagate, 'options.onPropagate');
287284
}
288285

289286
this.kResourceStore = Symbol('kResourceStore');

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.