11/*
2- * Copyright © 2024 Cloudnode OÜ
2+ * Copyright © 2024–2025 Cloudnode OÜ
33 *
44 * This file is part of @cldn/ip.
55 *
1717import { IPAddress , IPv4 , Subnet } from "./index.js" ;
1818
1919/**
20- * An IPv6 address
20+ * An IPv6 address.
2121 */
2222export class IPv6 extends IPAddress {
2323 public static bitLength = 128 ;
2424
2525 /**
26- * Create new IPv6 address instance
26+ * Creates a new IPv6 address instance.
27+ *
28+ * @param value A 128-bit unsigned big integer.
29+ * @throws {@link !TypeError } If provided value is not a 128-bit unsigned integer.
2730 */
2831 public constructor ( value : bigint ) {
2932 if ( value < 0n || value > ( ( 1n << BigInt ( IPv6 . bitLength ) ) - 1n ) )
@@ -32,8 +35,10 @@ export class IPv6 extends IPAddress {
3235 }
3336
3437 /**
35- * Create an IPv6 address instance from hextets
36- * @throws {@link !RangeError } If provided hextets are not 8
38+ * Creates an IPv6 address instance from hextets.
39+ *
40+ * @param hextets A typed array of 8 hextets.
41+ * @throws {@link !RangeError } If provided hextets are not 8.
3742 */
3843 public static fromBinary ( hextets : Uint16Array ) : IPv6 {
3944 if ( hextets . length !== 8 ) throw new RangeError ( "Expected 8 hextets, got " + hextets . length ) ;
@@ -51,8 +56,10 @@ export class IPv6 extends IPAddress {
5156 }
5257
5358 /**
54- * Create an IPv6 address instance from string
55- * @throws {@link !RangeError } If provided string is not a valid IPv6 address
59+ * Creates an IPv6 address instance from a string.
60+ *
61+ * @param str A string representation of an IPv6 address.
62+ * @throws {@link !RangeError } If provided string is not a valid IPv6 address.
5663 */
5764 public static override fromString ( str : string ) : IPv6 {
5865 const parts = str . split ( "::" , 2 ) ;
@@ -77,7 +84,7 @@ export class IPv6 extends IPAddress {
7784 }
7885
7986 /**
80- * Parse string hextet into unsigned 16-bit integer
87+ * Parses a string hextet into unsigned 16-bit integer.
8188 * @internal
8289 */
8390 private static parseHextet ( hextet : string ) : number | number [ ] {
@@ -92,7 +99,7 @@ export class IPv6 extends IPAddress {
9299 }
93100
94101 /**
95- * Get the 8 hextets of the IPv6 address
102+ * Gets the 8 hextets of the IPv6 address
96103 */
97104 public binary ( ) : Uint16Array {
98105 return new Uint16Array ( [
@@ -108,16 +115,16 @@ export class IPv6 extends IPAddress {
108115 }
109116
110117 /**
111- * Check whether this is an IPv4-mapped IPv6 address.
112- * Only works for `::ffff:0:0/96`
118+ * Checks whether this is an IPv4-mapped IPv6 address. Only works for `::ffff:0:0/96`.
113119 */
114120 public hasMappedIPv4 ( ) : boolean {
115121 return Subnet . IPV4_MAPPED_IPV6 . has ( this ) ;
116122 }
117123
118124 /**
119- * Get the IPv4-mapped IPv6 address.
120- * Returns the last 32 bits as an IPv4 address.
125+ * Gets the IPv4-mapped IPv6 address.
126+ *
127+ * @returns An IPv4 address from the least significant 32 bits of this IPv6 address.
121128 * @see {@link IPv6#hasMappedIPv4 }
122129 */
123130 public getMappedIPv4 ( ) : IPv4 {
0 commit comments