MCPcopy Create free account
hub / github.com/nodejs/node / validateCloseOptions

Function validateCloseOptions

lib/internal/quic/quic.js:5120–5140  ·  view source on GitHub ↗

* Validate and normalize close error options for session.close() and * session.destroy(). Returns the options object to pass to C++. * @param {object} options * @returns {object}

(options)

Source from the content-addressed store, hash-verified

5118 * @returns {object}
5119 */
5120function validateCloseOptions(options) {
5121 validateObject(options, 'options');
5122 const {
5123 code,
5124 type = 'transport',
5125 reason,
5126 } = options;
5127
5128 if (code !== undefined) {
5129 if (typeof code !== 'bigint' && typeof code !== 'number') {
5130 throw new ERR_INVALID_ARG_TYPE('options.code',
5131 ['bigint', 'number'], code);
5132 }
5133 }
5134 validateOneOf(type, 'options.type', ['transport', 'application']);
5135 if (reason !== undefined) {
5136 validateString(reason, 'options.reason');
5137 }
5138
5139 return { __proto__: null, code, type, reason };
5140}
5141
5142function getPreferredAddressPolicy(policy = 'default') {
5143 switch (policy) {

Callers 2

closeMethod · 0.85
destroyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected