net-address 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,395 +1,438 @@
1
1
  import { IOption, IResult } from "@luolapeikko/result-option";
2
-
3
2
  //#region src/Ipv6Addr.d.ts
4
3
  /**
5
- * Represents an IPv6 address.
6
- * @example
7
- * const addr1 = Ipv6Addr.from('2001:db8::1').unwrap();
8
- * const addr2 = new Ipv6Addr([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]);
9
- * const addr3 = new Ipv6Addr(0x20010db8000000000000000000000001n);
10
- * @since v0.0.1
11
- */
4
+ * Represents an IPv6 address.
5
+ * @example
6
+ * const addr1 = Ipv6Addr.from('2001:db8::1').unwrap();
7
+ * const addr2 = new Ipv6Addr([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]);
8
+ * const addr3 = new Ipv6Addr(0x20010db8000000000000000000000001n);
9
+ * @since v0.0.1
10
+ */
12
11
  declare class Ipv6Addr {
13
12
  #private;
14
13
  private static regex;
15
14
  /**
16
- * Creates an IPv6 address from text.
17
- * @returns A successful result with an IPv6 address, or an error when the input is invalid.
18
- * @example
19
- * const addr = Ipv6Addr.from('2001:db8::1').unwrap();
20
- * @since v0.0.1
21
- */
15
+ * Creates an IPv6 address from text.
16
+ * @returns A successful result with an IPv6 address, or an error when the input is invalid.
17
+ * @example
18
+ * const addr = Ipv6Addr.from('2001:db8::1').unwrap();
19
+ * @since v0.0.1
20
+ */
22
21
  static from(value: string): IResult<Ipv6Addr, TypeError | RangeError>;
23
22
  /**
24
- * Creates an IPv6 address from a 16-byte buffer.
25
- * @returns A successful result with an IPv6 address, or an error when the buffer cannot be read.
26
- * @since v0.0.1
27
- */
23
+ * Creates an IPv6 address from a 16-byte buffer.
24
+ * @returns A successful result with an IPv6 address, or an error when the buffer cannot be read.
25
+ * @since v0.0.1
26
+ */
28
27
  static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): IResult<Ipv6Addr>;
29
28
  /**
30
- * The number of bits in an IPv6 address.
31
- * @since v0.0.1
32
- */
29
+ * The number of bits in an IPv6 address.
30
+ * @since v0.0.1
31
+ */
33
32
  static readonly BITS = 128;
34
33
  /**
35
- * The loopback address (`::1`).
36
- * @since v0.0.1
37
- */
34
+ * The loopback address (`::1`).
35
+ * @since v0.0.1
36
+ */
38
37
  static readonly LOCALHOST: Ipv6Addr;
39
38
  /**
40
- * The unspecified address (`::`).
41
- * @since v0.0.1
42
- */
39
+ * The unspecified address (`::`).
40
+ * @since v0.0.1
41
+ */
43
42
  static readonly UNSPECIFIED: Ipv6Addr;
44
43
  /**
45
- * The address family identifier for IPv6 addresses.
46
- * @since v0.0.1
47
- */
44
+ * The address family identifier for IPv6 addresses.
45
+ * @since v0.0.1
46
+ */
48
47
  readonly family = "ipv6";
49
48
  /**
50
- * Creates a new IPv6 address instance.
51
- * @param value - A bigint representing the IPv6 address or an array of 8 numbers representing the segments of the address.
52
- * @throws {RangeError} If the segments array does not have exactly 8 elements or if any segment is out of range.
53
- * @throws {TypeError} If the input is neither a bigint nor an array of 8 numbers.
54
- */
49
+ * Gets the raw bigint representation of the IPv6 address.
50
+ */
51
+ get value(): bigint;
52
+ /**
53
+ * Creates a new IPv6 address instance.
54
+ * @param value - A bigint representing the IPv6 address or an array of 8 numbers representing the segments of the address.
55
+ * @throws {RangeError} If the segments array does not have exactly 8 elements or if any segment is out of range.
56
+ * @throws {TypeError} If the input is neither a bigint nor an array of 8 numbers.
57
+ */
55
58
  constructor(value: bigint);
56
59
  constructor(segments: [number, number, number, number, number, number, number, number]);
57
60
  /**
58
- * Checks whether this address is in the benchmarking range.
59
- * @see https://tools.ietf.org/html/rfc5180 and https://www.rfc-editor.org/errata_search.php?eid=1752
60
- * @returns `true` when the address is in `2001:2::/48`, otherwise `false`.
61
- * @since v0.0.1
62
- */
61
+ * Checks whether this address is in the benchmarking range.
62
+ * @see https://tools.ietf.org/html/rfc5180 and https://www.rfc-editor.org/errata_search.php?eid=1752
63
+ * @returns `true` when the address is in `2001:2::/48`, otherwise `false`.
64
+ * @since v0.0.1
65
+ */
63
66
  isBenchmarking(): boolean;
64
67
  /**
65
- * Checks whether this address is in a documentation-only range.
66
- * @see https://tools.ietf.org/html/rfc3849 and https://tools.ietf.org/html/rfc9637
67
- * @returns `true` for `2001:db8::/32` or `3fff::/20`, otherwise `false`.
68
- * @since v0.0.1
69
- */
68
+ * Checks whether this address is in a documentation-only range.
69
+ * @see https://tools.ietf.org/html/rfc3849 and https://tools.ietf.org/html/rfc9637
70
+ * @returns `true` for `2001:db8::/32` or `3fff::/20`, otherwise `false`.
71
+ * @since v0.0.1
72
+ */
70
73
  isDocumentation(): boolean;
71
74
  /**
72
- * Checks whether this address is the loopback address.
73
- * @see https://tools.ietf.org/html/rfc4291#section-2.5.3
74
- * @returns `true` when the address is `::1`, otherwise `false`.
75
- * @since v0.0.1
76
- */
75
+ * Checks whether this address is the loopback address.
76
+ * @see https://tools.ietf.org/html/rfc4291#section-2.5.3
77
+ * @returns `true` when the address is `::1`, otherwise `false`.
78
+ * @since v0.0.1
79
+ */
77
80
  isLoopback(): boolean;
78
81
  /**
79
- * Checks whether this address is the unspecified address.
80
- * @see https://tools.ietf.org/html/rfc4291
81
- * @returns `true` when the address is `::`, otherwise `false`.
82
- * @since v0.0.1
83
- */
82
+ * Checks whether this address is the unspecified address.
83
+ * @see https://tools.ietf.org/html/rfc4291
84
+ * @returns `true` when the address is `::`, otherwise `false`.
85
+ * @since v0.0.1
86
+ */
84
87
  isUnspecified(): boolean;
85
88
  /**
86
- * Checks whether this address is a multicast address.
87
- * @see https://tools.ietf.org/html/rfc4291
88
- * @returns `true` when the address is in `ff00::/8`, otherwise `false`.
89
- * @since v0.0.1
90
- */
89
+ * Checks whether this address is a multicast address.
90
+ * @see https://tools.ietf.org/html/rfc4291
91
+ * @returns `true` when the address is in `ff00::/8`, otherwise `false`.
92
+ * @since v0.0.1
93
+ */
91
94
  isMulticast(): boolean;
92
95
  /**
93
- * Checks whether this address is a multicast interface-local address.
94
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
95
- * @returns `true` when the address is in `ff01::/16`, otherwise `false`.
96
- * @since v0.0.2
97
- */
96
+ * Checks whether this address is a multicast interface-local address.
97
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
98
+ * @returns `true` when the address is in `ff01::/16`, otherwise `false`.
99
+ * @since v0.0.2
100
+ */
98
101
  isMulticastInterfaceLocal(): boolean;
99
102
  /**
100
- * Checks whether this address is a multicast link-local address.
101
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
102
- * @returns `true` when the address is in `ff02::/16`, otherwise `false`.
103
- * @since v0.0.2
104
- */
103
+ * Checks whether this address is a multicast link-local address.
104
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
105
+ * @returns `true` when the address is in `ff02::/16`, otherwise `false`.
106
+ * @since v0.0.2
107
+ */
105
108
  isMulticastLinkLocal(): boolean;
106
109
  /**
107
- * Checks whether this address is a multicast realm-local address.
108
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
109
- * @returns `true` when the address is in `ff03::/16`, otherwise `false`.
110
- * @since v0.0.2
111
- */
110
+ * Checks whether this address is a multicast realm-local address.
111
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
112
+ * @returns `true` when the address is in `ff03::/16`, otherwise `false`.
113
+ * @since v0.0.2
114
+ */
112
115
  isMulticastRealmLocal(): boolean;
113
116
  /**
114
- * Checks whether this address is a multicast admin-local address.
115
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
116
- * @returns `true` when the address is in `ff04::/16`, otherwise `false`.
117
- * @since v0.0.2
118
- */
117
+ * Checks whether this address is a multicast admin-local address.
118
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
119
+ * @returns `true` when the address is in `ff04::/16`, otherwise `false`.
120
+ * @since v0.0.2
121
+ */
119
122
  isMulticastAdminLocal(): boolean;
120
123
  /**
121
- * Checks whether this address is a multicast site-local address.
122
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
123
- * @returns `true` when the address is in `ff05::/16`, otherwise `false`.
124
- * @since v0.0.2
125
- */
124
+ * Checks whether this address is a multicast site-local address.
125
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
126
+ * @returns `true` when the address is in `ff05::/16`, otherwise `false`.
127
+ * @since v0.0.2
128
+ */
126
129
  isMulticastSiteLocal(): boolean;
127
130
  /**
128
- * Checks whether this address is a multicast organization-local address.
129
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
130
- * @returns `true` when the address is in `ff08::/16`, otherwise `false`.
131
- * @since v0.0.2
132
- */
131
+ * Checks whether this address is a multicast organization-local address.
132
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
133
+ * @returns `true` when the address is in `ff08::/16`, otherwise `false`.
134
+ * @since v0.0.2
135
+ */
133
136
  isMulticastOrganizationLocal(): boolean;
134
137
  /**
135
- * Checks whether this address is a multicast global address.
136
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
137
- * @returns `true` when the address is in `ff0e::/16`, otherwise `false`.
138
- * @since v0.0.2
139
- */
138
+ * Checks whether this address is a multicast global address.
139
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
140
+ * @returns `true` when the address is in `ff0e::/16`, otherwise `false`.
141
+ * @since v0.0.2
142
+ */
140
143
  isMulticastGlobal(): boolean;
141
144
  /**
142
- * Checks whether this address is an IPv4-mapped IPv6 address.
143
- * @returns `true` when the address is in `::ffff:0:0/96`, otherwise `false`.
144
- * @since v0.0.1
145
- */
145
+ * Checks whether this address is an IPv4-mapped IPv6 address.
146
+ * @returns `true` when the address is in `::ffff:0:0/96`, otherwise `false`.
147
+ * @since v0.0.1
148
+ */
146
149
  isIpv4Mapped(): boolean;
147
150
  /**
148
- * Checks whether this address is a unicast address.
149
- * @see https://tools.ietf.org/html/rfc4291
150
- * @returns `true` when the address is not multicast, otherwise `false`.
151
- * @since v0.0.1
152
- */
151
+ * Checks whether this address is a unicast address.
152
+ * @see https://tools.ietf.org/html/rfc4291
153
+ * @returns `true` when the address is not multicast, otherwise `false`.
154
+ * @since v0.0.1
155
+ */
153
156
  isUnicast(): boolean;
154
157
  /**
155
- * Checks whether this address is a link-local unicast address.
156
- * @see https://tools.ietf.org/html/rfc4291
157
- * @returns `true` when the address is in `fe80::/10`, otherwise `false`.
158
- * @since v0.0.1
159
- */
158
+ * Checks whether this address is a link-local unicast address.
159
+ * @see https://tools.ietf.org/html/rfc4291
160
+ * @returns `true` when the address is in `fe80::/10`, otherwise `false`.
161
+ * @since v0.0.1
162
+ */
160
163
  isUnicastLinkLocal(): boolean;
161
164
  /**
162
- * Checks whether this address is a global unicast address.
163
- * @see https://tools.ietf.org/html/rfc4291#section-2.5.7
164
- * @returns `true` when the address is unicast and not loopback, link-local, private, unspecified, or documentation.
165
- * @since v0.0.1
166
- */
165
+ * Checks whether this address is a global unicast address.
166
+ * @see https://tools.ietf.org/html/rfc4291#section-2.5.7
167
+ * @returns `true` when the address is unicast and not loopback, link-local, private, unspecified, or documentation.
168
+ * @since v0.0.1
169
+ */
167
170
  isUnicastGlobal(): boolean;
168
171
  /**
169
- * Checks whether this address appears globally reachable.
170
- * @see https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
171
- * @returns `true` when the address is not in known non-global special ranges.
172
- * @since v0.0.1
173
- */
172
+ * Checks whether this address appears globally reachable.
173
+ * @see https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
174
+ * @returns `true` when the address is not in known non-global special ranges.
175
+ * @since v0.0.1
176
+ */
174
177
  isGlobal(): boolean;
175
178
  /**
176
- * Checks whether this address is in the unique-local range.
177
- * @see https://tools.ietf.org/html/rfc4193
178
- * @returns `true` when the address is in `fc00::/7`, otherwise `false`.
179
- * @since v0.0.1
180
- */
179
+ * Checks whether this address is in the unique-local range.
180
+ * @see https://tools.ietf.org/html/rfc4193
181
+ * @returns `true` when the address is in `fc00::/7`, otherwise `false`.
182
+ * @since v0.0.1
183
+ */
181
184
  isUniqueLocal(): boolean;
182
185
  /**
183
- * Converts this address to IPv4 when compatible or mapped.
184
- * @returns An IPv4 address for `::a.b.c.d` or `::ffff:a.b.c.d`; otherwise `None`.
185
- * @since v0.0.1
186
- */
186
+ * Converts this address to IPv4 when compatible or mapped.
187
+ * @returns An IPv4 address for `::a.b.c.d` or `::ffff:a.b.c.d`; otherwise `None`.
188
+ * @since v0.0.1
189
+ */
187
190
  toIpv4(): IOption<Ipv4Addr>;
188
191
  /**
189
- * Converts this address to IPv4 only when it is IPv4-mapped.
190
- * @returns An IPv4 address for `::ffff:a.b.c.d`; otherwise `None`.
191
- * @since v0.0.1
192
- */
192
+ * Converts this address to IPv4 only when it is IPv4-mapped.
193
+ * @returns An IPv4 address for `::ffff:a.b.c.d`; otherwise `None`.
194
+ * @since v0.0.1
195
+ */
193
196
  toIpv4Mapped(): IOption<Ipv4Addr>;
194
197
  /**
195
- * Formats this address as a compressed IPv6 string.
196
- * @returns The shortest standard IPv6 text form.
197
- * @since v0.0.1
198
- */
198
+ * Formats this address as a compressed IPv6 string.
199
+ * @returns The shortest standard IPv6 text form.
200
+ * @since v0.0.1
201
+ */
199
202
  toString(): string;
200
203
  /**
201
- * Encodes this address to a 16-byte buffer.
202
- * @param littleEndian Whether to use little-endian byte order. Defaults to `false`.
203
- * @returns An `ArrayBuffer` containing the IPv6 integer value.
204
- * @since v0.0.1
205
- */
204
+ * Encodes this address to a 16-byte buffer.
205
+ * @param littleEndian Whether to use little-endian byte order. Defaults to `false`.
206
+ * @returns An `ArrayBuffer` containing the IPv6 integer value.
207
+ * @since v0.0.1
208
+ */
206
209
  toBuffer(littleEndian?: boolean): ArrayBuffer;
207
210
  /**
208
- * Compares this IPv6 address with another for equality.
209
- * @param other instance of another IPv6 address to compare with.
210
- * @returns `true` if both addresses are equal, otherwise `false`.
211
- * @since v0.1.0
212
- */
211
+ * Compares this IPv6 address with another for equality.
212
+ * @param other instance of another IPv6 address to compare with.
213
+ * @returns `true` if both addresses are equal, otherwise `false`.
214
+ * @since v0.1.0
215
+ */
213
216
  equals(other: Ipv6Addr | Ipv4Addr | object): boolean;
214
217
  }
215
218
  //#endregion
216
219
  //#region src/Ipv4Addr.d.ts
217
220
  /**
218
- * Represents an IPv4 address.
219
- * @example
220
- * const addr1 = Ipv4Addr.from('192.168.0.1').unwrap();
221
- * const addr2 = new Ipv4Addr(192, 168, 0, 1);
222
- * const addr3 = new Ipv4Addr(0xc0a80001);
223
- * @since v0.0.1
224
- */
221
+ * Represents an IPv4 address.
222
+ * @example
223
+ * const addr1 = Ipv4Addr.from('192.168.0.1').unwrap();
224
+ * const addr2 = new Ipv4Addr(192, 168, 0, 1);
225
+ * const addr3 = new Ipv4Addr(0xc0a80001);
226
+ * @since v0.0.1
227
+ */
225
228
  declare class Ipv4Addr {
226
229
  #private;
227
230
  /**
228
- * Creates an IPv4 address from dotted-decimal text.
229
- * @returns A successful {@link IResult} with an IPv4 address, or an error when the input is invalid.
230
- * @since v0.0.1
231
- */
231
+ * Creates an IPv4 address from dotted-decimal text.
232
+ * @returns A successful {@link IResult} with an IPv4 address, or an error when the input is invalid.
233
+ * @since v0.0.1
234
+ */
232
235
  static from(value: string): IResult<Ipv4Addr, TypeError>;
233
236
  /**
234
- * Creates an IPv4 address from a 4-byte buffer.
235
- * @returns A successful {@link IResult} with an IPv4 address, or an error when the buffer cannot be read.
236
- * @since v0.0.1
237
- */
237
+ * Creates an IPv4 address from a 4-byte buffer.
238
+ * @returns A successful {@link IResult} with an IPv4 address, or an error when the buffer cannot be read.
239
+ * @since v0.0.1
240
+ */
238
241
  static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): IResult<Ipv4Addr>;
239
242
  /**
240
- * The number of bits in an IPv4 address.
241
- * @since v0.0.1
242
- */
243
+ * The number of bits in an IPv4 address.
244
+ * @since v0.0.1
245
+ */
243
246
  static readonly BITS = 32;
244
247
  /**
245
- * The broadcast address `255.255.255.255`.
246
- * @since v0.0.1
247
- */
248
+ * The broadcast address `255.255.255.255`.
249
+ * @since v0.0.1
250
+ */
248
251
  static readonly BROADCAST: Ipv4Addr;
249
252
  /**
250
- * The localhost address `127.0.0.1`.
251
- * @since v0.0.1
252
- */
253
+ * The localhost address `127.0.0.1`.
254
+ * @since v0.0.1
255
+ */
253
256
  static readonly LOCALHOST: Ipv4Addr;
254
257
  /**
255
- * The unspecified address `0.0.0.0`.
256
- * @since v0.0.1
257
- */
258
+ * The unspecified address `0.0.0.0`.
259
+ * @since v0.0.1
260
+ */
258
261
  static readonly UNSPECIFIED: Ipv4Addr;
259
262
  /**
260
- * The address family identifier for IPv4 addresses.
261
- * @since v0.0.1
262
- */
263
+ * The address family identifier for IPv4 addresses.
264
+ * @since v0.0.1
265
+ */
263
266
  readonly family = "ipv4";
264
267
  /**
265
- * Creates a new IPv4 address from four octets.
266
- * @param num1 The first octet.
267
- * @param num2 The second octet.
268
- * @param num3 The third octet.
269
- * @param num4 The fourth octet.
270
- * @throws {RangeError} If the integer values are not in the range of 0 to 255 for each octet.
271
- * @throws {TypeError} If the input is not a number.
272
- * @example
273
- * new Ipv4Addr(192, 168, 0, 1) // creates the address `192.168.0.1`
274
- */
268
+ * Gets the raw integer representation of the IPv4 address.
269
+ */
270
+ get value(): number;
271
+ /**
272
+ * Creates a new IPv4 address from four octets.
273
+ * @param num1 The first octet.
274
+ * @param num2 The second octet.
275
+ * @param num3 The third octet.
276
+ * @param num4 The fourth octet.
277
+ * @throws {RangeError} If the integer values are not in the range of 0 to 255 for each octet.
278
+ * @throws {TypeError} If the input is not a number.
279
+ * @example
280
+ * new Ipv4Addr(192, 168, 0, 1) // creates the address `192.168.0.1`
281
+ */
275
282
  constructor(num1: number, num2: number, num3: number, num4: number);
276
283
  /**
277
- * Creates a new IPv4 address from an integer value.
278
- * @param integerValue The integer representation of the IPv4 address.
279
- * @throws {RangeError} If the integer value is not in the range of 0 to 0xffffffff.
280
- * @throws {TypeError} If the input is not a number.
281
- * @example
282
- * new Ipv4Addr(0xc0a80001) // creates the address `192.168.0.1` from the integer value `0xc0a80001`
283
- */
284
+ * Creates a new IPv4 address from an integer value.
285
+ * @param integerValue The integer representation of the IPv4 address.
286
+ * @throws {RangeError} If the integer value is not in the range of 0 to 0xffffffff.
287
+ * @throws {TypeError} If the input is not a number.
288
+ * @example
289
+ * new Ipv4Addr(0xc0a80001) // creates the address `192.168.0.1` from the integer value `0xc0a80001`
290
+ */
284
291
  constructor(integerValue: number);
285
292
  /**
286
- * Checks whether this address is the broadcast address.
287
- * @see https://datatracker.ietf.org/doc/html/rfc919#section-7
288
- * @returns `true` when the address is `255.255.255.255`, otherwise `false`.
289
- * @since v0.0.1
290
- */
293
+ * Checks whether this address is the broadcast address.
294
+ * @see https://datatracker.ietf.org/doc/html/rfc919#section-7
295
+ * @returns `true` when the address is `255.255.255.255`, otherwise `false`.
296
+ * @since v0.0.1
297
+ */
291
298
  isBroadcast(): boolean;
292
299
  /**
293
- * Checks whether this address is in a documentation-only range.
294
- * @see https://datatracker.ietf.org/doc/html/rfc5737
295
- * @returns `true` for `192.0.2.0/24`, `198.51.100.0/24`, or `203.0.113.0/24`; otherwise `false`.
296
- * @since v0.0.1
297
- */
300
+ * Checks whether this address is in a documentation-only range.
301
+ * @see https://datatracker.ietf.org/doc/html/rfc5737
302
+ * @returns `true` for `192.0.2.0/24`, `198.51.100.0/24`, or `203.0.113.0/24`; otherwise `false`.
303
+ * @since v0.0.1
304
+ */
298
305
  isDocumentation(): boolean;
299
306
  /**
300
- * Checks whether this address is in the benchmarking range.
301
- * @see https://datatracker.ietf.org/doc/html/rfc2544
302
- * @returns `true` when the address is in `198.18.0.0/15`, otherwise `false`.
303
- * @since v0.0.1
304
- */
307
+ * Checks whether this address is in the benchmarking range.
308
+ * @see https://datatracker.ietf.org/doc/html/rfc2544
309
+ * @returns `true` when the address is in `198.18.0.0/15`, otherwise `false`.
310
+ * @since v0.0.1
311
+ */
305
312
  isBenchmarking(): boolean;
306
313
  /**
307
- * Checks whether this address is globally reachable.
308
- * @see https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
309
- * @returns `true` when the address is not in any special non-global range.
310
- * @since v0.0.1
311
- */
314
+ * Checks whether this address is globally reachable.
315
+ * @see https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
316
+ * @returns `true` when the address is not in any special non-global range.
317
+ * @since v0.0.1
318
+ */
312
319
  isGlobal(): boolean;
313
320
  /**
314
- * Checks whether this address is link-local.
315
- * @see https://datatracker.ietf.org/doc/html/rfc3927
316
- * @returns `true` when the address is in `169.254.0.0/16`, otherwise `false`.
317
- * @since v0.0.1
318
- */
321
+ * Checks whether this address is link-local.
322
+ * @see https://datatracker.ietf.org/doc/html/rfc3927
323
+ * @returns `true` when the address is in `169.254.0.0/16`, otherwise `false`.
324
+ * @since v0.0.1
325
+ */
319
326
  isLinkLocal(): boolean;
320
327
  /**
321
- * Checks whether this address is a loopback address.
322
- * @see https://datatracker.ietf.org/doc/html/rfc1122
323
- * @returns `true` when the address is in `127.0.0.0/8`, otherwise `false`.
324
- * @since v0.0.1
325
- */
328
+ * Checks whether this address is a loopback address.
329
+ * @see https://datatracker.ietf.org/doc/html/rfc1122
330
+ * @returns `true` when the address is in `127.0.0.0/8`, otherwise `false`.
331
+ * @since v0.0.1
332
+ */
326
333
  isLoopback(): boolean;
327
334
  /**
328
- * Checks whether this address is a multicast address.
329
- * @see https://datatracker.ietf.org/doc/html/rfc5771
330
- * @returns `true` when the address is in `224.0.0.0/4`, otherwise `false`.
331
- * @since v0.0.1
332
- */
335
+ * Checks whether this address is a multicast address.
336
+ * @see https://datatracker.ietf.org/doc/html/rfc5771
337
+ * @returns `true` when the address is in `224.0.0.0/4`, otherwise `false`.
338
+ * @since v0.0.1
339
+ */
333
340
  isMulticast(): boolean;
334
341
  /**
335
- * Checks whether this address is in a private-use range.
336
- * @see https://datatracker.ietf.org/doc/html/rfc1918
337
- * @returns `true` for `10.0.0.0/8`, `172.16.0.0/12`, or `192.168.0.0/16`; otherwise `false`.
338
- * @since v0.0.1
339
- */
342
+ * Checks whether this address is in a private-use range.
343
+ * @see https://datatracker.ietf.org/doc/html/rfc1918
344
+ * @returns `true` for `10.0.0.0/8`, `172.16.0.0/12`, or `192.168.0.0/16`; otherwise `false`.
345
+ * @since v0.0.1
346
+ */
340
347
  isPrivate(): boolean;
341
348
  /**
342
- * Checks whether this address is in the reserved range.
343
- * @see https://datatracker.ietf.org/doc/html/rfc1112
344
- * @returns `true` when the address is in `240.0.0.0/4` except the broadcast address.
345
- * @since v0.0.1
346
- */
349
+ * Checks whether this address is in the reserved range.
350
+ * @see https://datatracker.ietf.org/doc/html/rfc1112
351
+ * @returns `true` when the address is in `240.0.0.0/4` except the broadcast address.
352
+ * @since v0.0.1
353
+ */
347
354
  isReserved(): boolean;
348
355
  /**
349
- * Checks whether this address is in the shared Carrier-Grade NAT range.
350
- * @see https://datatracker.ietf.org/doc/html/rfc6598
351
- * @returns `true` when the address is in `100.64.0.0/10`, otherwise `false`.
352
- * @since v0.0.1
353
- */
356
+ * Checks whether this address is in the shared Carrier-Grade NAT range.
357
+ * @see https://datatracker.ietf.org/doc/html/rfc6598
358
+ * @returns `true` when the address is in `100.64.0.0/10`, otherwise `false`.
359
+ * @since v0.0.1
360
+ */
354
361
  isShared(): boolean;
355
362
  /**
356
- * Checks whether this address is the unspecified address.
357
- * @returns `true` when the address is `0.0.0.0`, otherwise `false`.
358
- * @since v0.0.1
359
- */
363
+ * Checks whether this address is the unspecified address.
364
+ * @returns `true` when the address is `0.0.0.0`, otherwise `false`.
365
+ * @since v0.0.1
366
+ */
360
367
  isUnspecified(): boolean;
361
368
  /**
362
- * Converts this address to an IPv4-compatible IPv6 address.
363
- * @returns An IPv6 address in the form `::a.b.c.d`.
364
- * @since v0.0.1
365
- */
369
+ * Converts this address to an IPv4-compatible IPv6 address.
370
+ * @returns An IPv6 address in the form `::a.b.c.d`.
371
+ * @since v0.0.1
372
+ */
366
373
  toIpv6(): Ipv6Addr;
367
374
  /**
368
- * Converts this address to an IPv4-mapped IPv6 address.
369
- * @returns An IPv6 address in the form `::ffff:a.b.c.d`.
370
- * @since v0.0.1
371
- */
375
+ * Converts this address to an IPv4-mapped IPv6 address.
376
+ * @returns An IPv6 address in the form `::ffff:a.b.c.d`.
377
+ * @since v0.0.1
378
+ */
372
379
  toIpv6Mapped(): Ipv6Addr;
373
380
  /**
374
- * Formats this address as dotted-decimal text.
375
- * @returns The IPv4 string representation, such as `192.168.0.1`.
376
- * @since v0.0.1
377
- */
381
+ * Formats this address as dotted-decimal text.
382
+ * @returns The IPv4 string representation, such as `192.168.0.1`.
383
+ * @since v0.0.1
384
+ */
378
385
  toString(): string;
379
386
  /**
380
- * Encodes this address to a 4-byte buffer.
381
- * @returns An `ArrayBuffer` containing the IPv4 integer value.
382
- * @since v0.0.1
383
- */
387
+ * Encodes this address to a 4-byte buffer.
388
+ * @returns An `ArrayBuffer` containing the IPv4 integer value.
389
+ * @since v0.0.1
390
+ */
384
391
  toBuffer(littleEndian?: boolean): ArrayBuffer;
385
392
  /**
386
- * Compares this IPv4 address with another for equality.
387
- * @param other instance of another IPv4 address to compare with.
388
- * @returns `true` if both addresses are equal, otherwise `false`.
389
- * @since v0.1.0
390
- */
393
+ * Compares this IPv4 address with another for equality.
394
+ * @param other instance of another IPv4 address to compare with.
395
+ * @returns `true` if both addresses are equal, otherwise `false`.
396
+ * @since v0.1.0
397
+ */
391
398
  equals(other: Ipv4Addr | Ipv6Addr | object): boolean;
392
399
  }
393
400
  //#endregion
394
- export { Ipv4Addr, Ipv6Addr };
401
+ //#region src/Ipv4Net.d.ts
402
+ /**
403
+ * Represents an IPv4 network.
404
+ * @example
405
+ * const addr = Ipv4Addr.from('192.168.0.1').unwrap();
406
+ * const network = Ipv4Net.fromAddr(addr, 24);
407
+ * @since v0.1.2
408
+ */
409
+ declare class Ipv4Net {
410
+ #private;
411
+ readonly address: Ipv4Addr;
412
+ readonly size: number;
413
+ private constructor();
414
+ static fromAddr(address: Ipv4Addr, size: number): Ipv4Net;
415
+ static from(value: string): Ipv4Net;
416
+ isInRange(address: Ipv4Addr): boolean;
417
+ }
418
+ //#endregion
419
+ //#region src/Ipv6Net.d.ts
420
+ /**
421
+ * Represents an IPv6 network.
422
+ * @example
423
+ * const addr = Ipv6Addr.from('2001:db8::1').unwrap();
424
+ * const network = Ipv6Net.fromAddr(addr, 64);
425
+ * @since v0.1.2
426
+ */
427
+ declare class Ipv6Net {
428
+ #private;
429
+ readonly address: Ipv6Addr;
430
+ readonly size: number;
431
+ private constructor();
432
+ static fromAddr(address: Ipv6Addr, size: number): Ipv6Net;
433
+ static from(value: string): Ipv6Net;
434
+ isInRange(address: Ipv6Addr): boolean;
435
+ }
436
+ //#endregion
437
+ export { Ipv4Addr, Ipv4Net, Ipv6Addr, Ipv6Net };
395
438
  //# sourceMappingURL=index.d.cts.map