cidr-block 1.2.0 → 1.3.0

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.
@@ -4,7 +4,7 @@ import { Ipv4Literal, Ipv4Representable } from './types';
4
4
  * checking.
5
5
  *
6
6
  * @remarks
7
- * Direct instantiation should be avoided; use {@link ipv4.address|ipv4.address()} instead.
7
+ * Direct instantiation should be avoided; use {@link ipv4.address} instead.
8
8
  */
9
9
  export declare class Ipv4Address {
10
10
  private _address;
@@ -18,8 +18,8 @@ export declare class Ipv4Address {
18
18
  * ```typescript
19
19
  * import { ipv4 as ip } from 'cidr-block'
20
20
  *
21
- * ip.address(255n) // ==> '0.0.0.255'
22
- * ip.address(0b11111111_00000000_11111111_00000000n) // ==> '255.0.255.0'
21
+ * ip.address(255) // ==> '0.0.0.255'
22
+ * ip.address(0b11111111_00000000_11111111_00000000) // ==> '255.0.255.0'
23
23
  * ````
24
24
  *
25
25
  * @public
@@ -102,8 +102,8 @@ export declare function address(ip: Ipv4Literal): Ipv4Address;
102
102
  * ```typescript
103
103
  * import * as cidr from 'cidr-block'
104
104
  *
105
- * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295n // ==> true
106
- * cidr.ipv4.stringToNum('0.0.0.255') === 255n // ==> true
105
+ * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295 // ==> true
106
+ * cidr.ipv4.stringToNum('0.0.0.255') === 255 // ==> true
107
107
  * ```
108
108
  *
109
109
  * @see This method is the inverse of {@link ipv4.numToString}
@@ -122,9 +122,9 @@ export declare function stringToNum(address: string): number;
122
122
  * ```typescript
123
123
  * import * as cidr from 'cidr-block'
124
124
  *
125
- * cidr.ipv4.numToString(0n) === '0.0.0.0' // ==> true
126
- * cidr.ipv4.numToString(65_280n) === '0.0.255.0' // ==> true
127
- * cidr.ipv4.numToString(4_294_967_295n) === '255.255.255.255' // ==> true
125
+ * cidr.ipv4.numToString(0) === '0.0.0.0' // ==> true
126
+ * cidr.ipv4.numToString(65_280) === '0.0.255.0' // ==> true
127
+ * cidr.ipv4.numToString(4_294_967_295) === '255.255.255.255' // ==> true
128
128
  * ```
129
129
  *
130
130
  * @see This method is the inverse of {@link ipv4.stringToNum}
@@ -0,0 +1,13 @@
1
+ import { Ipv6Literal, Ipv6Representable } from './types';
2
+ export declare class Ipv6Address {
3
+ private _address;
4
+ constructor(address: Ipv6Literal);
5
+ get address(): bigint;
6
+ toString(): string;
7
+ equals(otherIpAddress: Ipv6Representable): boolean;
8
+ nextIp(): Ipv6Address;
9
+ previousIp(): Ipv6Address;
10
+ }
11
+ export declare function address(ip: Ipv6Literal): Ipv6Address;
12
+ export declare function stringToNum(address: string): bigint;
13
+ export declare function numToString(num: bigint): string;
@@ -0,0 +1,9 @@
1
+ import { Ipv6Address } from './ipv6-address';
2
+ /**
3
+ * Type that indicates a literal string or number value that represents an IPv6 address
4
+ */
5
+ export declare type Ipv6Literal = string | bigint;
6
+ /**
7
+ * Type that indicates either a literal value or an address instance that is an IPv6
8
+ */
9
+ export declare type Ipv6Representable = Ipv6Address | Ipv6Literal;
@@ -16,7 +16,7 @@ const MAX$1 = 2 ** 32 - 1;const MAX_OCTET_SIZE = 255;
16
16
  * checking.
17
17
  *
18
18
  * @remarks
19
- * Direct instantiation should be avoided; use {@link ipv4.address|ipv4.address()} instead.
19
+ * Direct instantiation should be avoided; use {@link ipv4.address} instead.
20
20
  */
21
21
  class Ipv4Address {
22
22
  _address;
@@ -34,8 +34,8 @@ class Ipv4Address {
34
34
  * ```typescript
35
35
  * import { ipv4 as ip } from 'cidr-block'
36
36
  *
37
- * ip.address(255n) // ==> '0.0.0.255'
38
- * ip.address(0b11111111_00000000_11111111_00000000n) // ==> '255.0.255.0'
37
+ * ip.address(255) // ==> '0.0.0.255'
38
+ * ip.address(0b11111111_00000000_11111111_00000000) // ==> '255.0.255.0'
39
39
  * ````
40
40
  *
41
41
  * @public
@@ -133,8 +133,8 @@ function address(ip) {
133
133
  * ```typescript
134
134
  * import * as cidr from 'cidr-block'
135
135
  *
136
- * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295n // ==> true
137
- * cidr.ipv4.stringToNum('0.0.0.255') === 255n // ==> true
136
+ * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295 // ==> true
137
+ * cidr.ipv4.stringToNum('0.0.0.255') === 255 // ==> true
138
138
  * ```
139
139
  *
140
140
  * @see This method is the inverse of {@link ipv4.numToString}
@@ -171,9 +171,9 @@ function stringToNum(address) {
171
171
  * ```typescript
172
172
  * import * as cidr from 'cidr-block'
173
173
  *
174
- * cidr.ipv4.numToString(0n) === '0.0.0.0' // ==> true
175
- * cidr.ipv4.numToString(65_280n) === '0.0.255.0' // ==> true
176
- * cidr.ipv4.numToString(4_294_967_295n) === '255.255.255.255' // ==> true
174
+ * cidr.ipv4.numToString(0) === '0.0.0.0' // ==> true
175
+ * cidr.ipv4.numToString(65_280) === '0.0.255.0' // ==> true
176
+ * cidr.ipv4.numToString(4_294_967_295) === '255.255.255.255' // ==> true
177
177
  * ```
178
178
  *
179
179
  * @see This method is the inverse of {@link ipv4.stringToNum}
package/build/index.js CHANGED
@@ -16,7 +16,7 @@ const MAX$1 = 2 ** 32 - 1;const MAX_OCTET_SIZE = 255;
16
16
  * checking.
17
17
  *
18
18
  * @remarks
19
- * Direct instantiation should be avoided; use {@link ipv4.address|ipv4.address()} instead.
19
+ * Direct instantiation should be avoided; use {@link ipv4.address} instead.
20
20
  */
21
21
  class Ipv4Address {
22
22
  _address;
@@ -34,8 +34,8 @@ class Ipv4Address {
34
34
  * ```typescript
35
35
  * import { ipv4 as ip } from 'cidr-block'
36
36
  *
37
- * ip.address(255n) // ==> '0.0.0.255'
38
- * ip.address(0b11111111_00000000_11111111_00000000n) // ==> '255.0.255.0'
37
+ * ip.address(255) // ==> '0.0.0.255'
38
+ * ip.address(0b11111111_00000000_11111111_00000000) // ==> '255.0.255.0'
39
39
  * ````
40
40
  *
41
41
  * @public
@@ -133,8 +133,8 @@ function address(ip) {
133
133
  * ```typescript
134
134
  * import * as cidr from 'cidr-block'
135
135
  *
136
- * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295n // ==> true
137
- * cidr.ipv4.stringToNum('0.0.0.255') === 255n // ==> true
136
+ * cidr.ipv4.stringToNum('255.255.255.255') === 4_294_967_295 // ==> true
137
+ * cidr.ipv4.stringToNum('0.0.0.255') === 255 // ==> true
138
138
  * ```
139
139
  *
140
140
  * @see This method is the inverse of {@link ipv4.numToString}
@@ -171,9 +171,9 @@ function stringToNum(address) {
171
171
  * ```typescript
172
172
  * import * as cidr from 'cidr-block'
173
173
  *
174
- * cidr.ipv4.numToString(0n) === '0.0.0.0' // ==> true
175
- * cidr.ipv4.numToString(65_280n) === '0.0.255.0' // ==> true
176
- * cidr.ipv4.numToString(4_294_967_295n) === '255.255.255.255' // ==> true
174
+ * cidr.ipv4.numToString(0) === '0.0.0.0' // ==> true
175
+ * cidr.ipv4.numToString(65_280) === '0.0.255.0' // ==> true
176
+ * cidr.ipv4.numToString(4_294_967_295) === '255.255.255.255' // ==> true
177
177
  * ```
178
178
  *
179
179
  * @see This method is the inverse of {@link ipv4.stringToNum}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cidr-block",
3
3
  "description": "ipv4 and ipv6 address and cidr range utilities",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "license": "MIT",
6
6
  "author": "Brandon Burrus <brandon@burrus.io>",
7
7
  "homepage": "https://cidr-block.com",