* 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)
| 5118 | * @returns {object} |
| 5119 | */ |
| 5120 | function 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 | |
| 5142 | function getPreferredAddressPolicy(policy = 'default') { |
| 5143 | switch (policy) { |