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