MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/internal/socketaddress.js:50–86  ·  view source on GitHub ↗
(options = kEmptyObject)

Source from the content-addressed store, hash-verified

48 }
49
50 constructor(options = kEmptyObject) {
51 markTransferMode(this, true, false);
52
53 validateObject(options, 'options');
54 let { family = 'ipv4' } = options;
55 const {
56 address = (family === 'ipv4' ? '127.0.0.1' : '::'),
57 port = 0,
58 flowlabel = 0,
59 } = options;
60
61 let type;
62 if (typeof family?.toLowerCase === 'function')
63 family = family.toLowerCase();
64 switch (family) {
65 case 'ipv4':
66 type = AF_INET;
67 break;
68 case 'ipv6':
69 type = AF_INET6;
70 break;
71 default:
72 throw new ERR_INVALID_ARG_VALUE('options.family', options.family);
73 }
74
75 validateString(address, 'options.address');
76 validatePort(port, 'options.port');
77 validateUint32(flowlabel, 'options.flowlabel', false);
78
79 this[kHandle] = new _SocketAddress(address, port | 0, type, flowlabel | 0);
80 this[kDetail] = this[kHandle].detail({
81 address: undefined,
82 port: undefined,
83 family: undefined,
84 flowlabel: undefined,
85 });
86 }
87
88 get address() {
89 return this[kDetail].address;

Callers

nothing calls this directly

Calls 2

markTransferModeFunction · 0.85
detailMethod · 0.45

Tested by

no test coverage detected