ipv4.d.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. import * as common from './common';
  2. /**
  3. * Represents an IPv4 address
  4. * @class Address4
  5. * @param {string} address - An IPv4 address string
  6. */
  7. export declare class Address4 {
  8. address: string;
  9. addressMinusSuffix?: string;
  10. groups: number;
  11. parsedAddress: string[];
  12. parsedSubnet: string;
  13. subnet: string;
  14. subnetMask: number;
  15. v4: boolean;
  16. constructor(address: string);
  17. static isValid(address: string): boolean;
  18. parse(address: string): string[];
  19. /**
  20. * Returns the correct form of an address
  21. * @memberof Address4
  22. * @instance
  23. * @returns {String}
  24. */
  25. correctForm(): string;
  26. /**
  27. * Returns true if the address is correct, false otherwise
  28. * @memberof Address4
  29. * @instance
  30. * @returns {Boolean}
  31. */
  32. isCorrect: (this: Address4 | import("./ipv6").Address6) => boolean;
  33. /**
  34. * Converts a hex string to an IPv4 address object
  35. * @memberof Address4
  36. * @static
  37. * @param {string} hex - a hex string to convert
  38. * @returns {Address4}
  39. */
  40. static fromHex(hex: string): Address4;
  41. /**
  42. * Converts an integer into a IPv4 address object
  43. * @memberof Address4
  44. * @static
  45. * @param {integer} integer - a number to convert
  46. * @returns {Address4}
  47. */
  48. static fromInteger(integer: number): Address4;
  49. /**
  50. * Return an address from in-addr.arpa form
  51. * @memberof Address4
  52. * @static
  53. * @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address
  54. * @returns {Adress4}
  55. * @example
  56. * var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.)
  57. * address.correctForm(); // '192.0.2.42'
  58. */
  59. static fromArpa(arpaFormAddress: string): Address4;
  60. /**
  61. * Converts an IPv4 address object to a hex string
  62. * @memberof Address4
  63. * @instance
  64. * @returns {String}
  65. */
  66. toHex(): string;
  67. /**
  68. * Converts an IPv4 address object to an array of bytes
  69. * @memberof Address4
  70. * @instance
  71. * @returns {Array}
  72. */
  73. toArray(): number[];
  74. /**
  75. * Converts an IPv4 address object to an IPv6 address group
  76. * @memberof Address4
  77. * @instance
  78. * @returns {String}
  79. */
  80. toGroup6(): string;
  81. /**
  82. * Returns the address as a `bigint`
  83. * @memberof Address4
  84. * @instance
  85. * @returns {bigint}
  86. */
  87. bigInt(): bigint;
  88. /**
  89. * Helper function getting start address.
  90. * @memberof Address4
  91. * @instance
  92. * @returns {bigint}
  93. */
  94. _startAddress(): bigint;
  95. /**
  96. * The first address in the range given by this address' subnet.
  97. * Often referred to as the Network Address.
  98. * @memberof Address4
  99. * @instance
  100. * @returns {Address4}
  101. */
  102. startAddress(): Address4;
  103. /**
  104. * The first host address in the range given by this address's subnet ie
  105. * the first address after the Network Address
  106. * @memberof Address4
  107. * @instance
  108. * @returns {Address4}
  109. */
  110. startAddressExclusive(): Address4;
  111. /**
  112. * Helper function getting end address.
  113. * @memberof Address4
  114. * @instance
  115. * @returns {bigint}
  116. */
  117. _endAddress(): bigint;
  118. /**
  119. * The last address in the range given by this address' subnet
  120. * Often referred to as the Broadcast
  121. * @memberof Address4
  122. * @instance
  123. * @returns {Address4}
  124. */
  125. endAddress(): Address4;
  126. /**
  127. * The last host address in the range given by this address's subnet ie
  128. * the last address prior to the Broadcast Address
  129. * @memberof Address4
  130. * @instance
  131. * @returns {Address4}
  132. */
  133. endAddressExclusive(): Address4;
  134. /**
  135. * Converts a BigInt to a v4 address object
  136. * @memberof Address4
  137. * @static
  138. * @param {bigint} bigInt - a BigInt to convert
  139. * @returns {Address4}
  140. */
  141. static fromBigInt(bigInt: bigint): Address4;
  142. /**
  143. * Convert a byte array to an Address4 object
  144. * @memberof Address4
  145. * @static
  146. * @param {Array<number>} bytes - an array of 4 bytes (0-255)
  147. * @returns {Address4}
  148. */
  149. static fromByteArray(bytes: Array<number>): Address4;
  150. /**
  151. * Convert an unsigned byte array to an Address4 object
  152. * @memberof Address4
  153. * @static
  154. * @param {Array<number>} bytes - an array of 4 unsigned bytes (0-255)
  155. * @returns {Address4}
  156. */
  157. static fromUnsignedByteArray(bytes: Array<number>): Address4;
  158. /**
  159. * Returns the first n bits of the address, defaulting to the
  160. * subnet mask
  161. * @memberof Address4
  162. * @instance
  163. * @returns {String}
  164. */
  165. mask(mask?: number): string;
  166. /**
  167. * Returns the bits in the given range as a base-2 string
  168. * @memberof Address4
  169. * @instance
  170. * @returns {string}
  171. */
  172. getBitsBase2(start: number, end: number): string;
  173. /**
  174. * Return the reversed ip6.arpa form of the address
  175. * @memberof Address4
  176. * @param {Object} options
  177. * @param {boolean} options.omitSuffix - omit the "in-addr.arpa" suffix
  178. * @instance
  179. * @returns {String}
  180. */
  181. reverseForm(options?: common.ReverseFormOptions): string;
  182. /**
  183. * Returns true if the given address is in the subnet of the current address
  184. * @memberof Address4
  185. * @instance
  186. * @returns {boolean}
  187. */
  188. isInSubnet: typeof common.isInSubnet;
  189. /**
  190. * Returns true if the given address is a multicast address
  191. * @memberof Address4
  192. * @instance
  193. * @returns {boolean}
  194. */
  195. isMulticast(): boolean;
  196. /**
  197. * Returns a zero-padded base-2 string representation of the address
  198. * @memberof Address4
  199. * @instance
  200. * @returns {string}
  201. */
  202. binaryZeroPad(): string;
  203. /**
  204. * Groups an IPv4 address for inclusion at the end of an IPv6 address
  205. * @returns {String}
  206. */
  207. groupForV6(): string;
  208. }
  209. //# sourceMappingURL=ipv4.d.ts.map