ipaddress 0.2.6 → 0.2.9

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.
Files changed (57) hide show
  1. package/dist/src/crunchy.d.ts +107 -33
  2. package/dist/src/crunchy.d.ts.map +1 -1
  3. package/dist/src/crunchy.js +274 -142
  4. package/dist/src/ip_bits.d.ts +2 -2
  5. package/dist/src/ip_bits.d.ts.map +1 -1
  6. package/dist/src/ipaddress.d.ts +24 -23
  7. package/dist/src/ipaddress.d.ts.map +1 -1
  8. package/dist/src/ipaddress.js +22 -7
  9. package/dist/src/ipv4.d.ts +3 -3
  10. package/dist/src/ipv4.d.ts.map +1 -1
  11. package/dist/src/ipv4.js +26 -15
  12. package/dist/src/ipv6.d.ts +4 -4
  13. package/dist/src/ipv6.d.ts.map +1 -1
  14. package/dist/src/ipv6.js +1 -1
  15. package/dist/src/ipv6_loopback.d.ts +1 -1
  16. package/dist/src/ipv6_loopback.d.ts.map +1 -1
  17. package/dist/src/ipv6_mapped.d.ts +1 -1
  18. package/dist/src/ipv6_mapped.d.ts.map +1 -1
  19. package/dist/src/ipv6_unspec.d.ts +1 -1
  20. package/dist/src/ipv6_unspec.d.ts.map +1 -1
  21. package/dist/src/prefix128.d.ts +1 -1
  22. package/dist/src/prefix128.d.ts.map +1 -1
  23. package/dist/src/prefix128.js +5 -1
  24. package/dist/src/prefix32.d.ts +1 -1
  25. package/dist/src/prefix32.d.ts.map +1 -1
  26. package/dist/src/prefix32.js +5 -1
  27. package/dist/test/test_crunchy_impls.d.ts +2 -0
  28. package/dist/test/test_crunchy_impls.d.ts.map +1 -0
  29. package/dist/test/test_crunchy_impls.js +150 -0
  30. package/dist/test/test_crunchy_with32bit.d.ts +2 -0
  31. package/dist/test/test_crunchy_with32bit.d.ts.map +1 -0
  32. package/dist/test/{test_crunchy.js → test_crunchy_with32bit.js} +113 -182
  33. package/dist/test/test_ipv4.js +1 -1
  34. package/dist/test/test_ipv6.js +1 -1
  35. package/package.json +10 -9
  36. package/src/crunchy.ts +365 -180
  37. package/src/ip_bits.ts +11 -11
  38. package/src/ipaddress.ts +49 -33
  39. package/src/ipv4.ts +32 -19
  40. package/src/ipv6.ts +6 -6
  41. package/src/ipv6_loopback.ts +1 -1
  42. package/src/ipv6_mapped.ts +1 -1
  43. package/src/ipv6_unspec.ts +1 -1
  44. package/src/prefix128.ts +6 -2
  45. package/src/prefix32.ts +6 -2
  46. package/test/test_crunchy_impls.ts +179 -0
  47. package/test/{test_crunchy.ts → test_crunchy_with32bit.ts} +131 -235
  48. package/test/test_ipaddress.ts +9 -9
  49. package/test/test_ipv4.ts +115 -115
  50. package/test/test_ipv6.ts +62 -62
  51. package/test/test_ipv6_loopback.ts +1 -1
  52. package/test/test_ipv6_mapped.ts +4 -4
  53. package/test/test_ipv6_unspec.ts +1 -1
  54. package/test/test_prefix128.ts +2 -2
  55. package/test/test_prefix32.ts +13 -13
  56. package/dist/test/test_crunchy.d.ts +0 -2
  57. package/dist/test/test_crunchy.d.ts.map +0 -1
package/test/test_ipv6.ts CHANGED
@@ -8,8 +8,8 @@ class IPv6Test {
8
8
  valid_ipv6: [string, Crunchy][] = [];
9
9
  invalid_ipv6: string[] = [":1:2:3:4:5:6:7", ":1:2:3:4:5:6:7", "2002:516:2:200", "dd"];
10
10
  networks: [string, string][] = [];
11
- ip: IPAddress = IPAddress.parse("2001:db8::8:800:200c:417a/64");
12
- network: IPAddress = IPAddress.parse("2001:db8:8:800::/64");
11
+ ip: IPAddress = IPAddress.parse("2001:db8::8:800:200c:417a/64")!;
12
+ network: IPAddress = IPAddress.parse("2001:db8:8:800::/64")!;
13
13
  arr: number[] = [8193, 3512, 0, 0, 8, 2048, 8204, 16762];
14
14
  hex = "20010db80000000000080800200c417a";
15
15
  }
@@ -82,21 +82,21 @@ describe("ipv6", () => {
82
82
  for (const i of setup().valid_ipv6) {
83
83
  const ip = i[0];
84
84
  const num = i[1];
85
- assert.isOk(num.eq(IPAddress.parse(ip).host_address));
85
+ assert.isOk(num.eq(IPAddress.parse(ip)!.host_address));
86
86
  }
87
87
  });
88
88
  it("test_method_set_prefix", () => {
89
89
  const ip = IPAddress.parse("2001:db8::8:800:200c:417a");
90
- assert.equal(128, ip.prefix.num);
91
- assert.equal("2001:db8::8:800:200c:417a/128", ip.to_string());
92
- const nip = ip.change_prefix(64);
93
- assert.equal(64, nip.prefix.num);
94
- assert.equal("2001:db8::8:800:200c:417a/64", nip.to_string());
90
+ assert.equal(128, ip!.prefix.num);
91
+ assert.equal("2001:db8::8:800:200c:417a/128", ip!.to_string());
92
+ const nip = ip!.change_prefix(64);
93
+ assert.equal(64, nip!.prefix.num);
94
+ assert.equal("2001:db8::8:800:200c:417a/64", nip!.to_string());
95
95
  });
96
96
  it("test_method_mapped", () => {
97
97
  assert.equal(false, setup().ip.is_mapped());
98
98
  const ip6 = IPAddress.parse("::ffff:1234:5678");
99
- assert.equal(true, ip6.is_mapped());
99
+ assert.equal(true, ip6!.is_mapped());
100
100
  });
101
101
  it("test_method_group", () => {
102
102
  const s = setup();
@@ -113,20 +113,20 @@ describe("ipv6", () => {
113
113
  assert.equal(false, setup().ip.is_network());
114
114
  });
115
115
  it("test_method_network_u128", () => {
116
- assert.isOk(Ipv6.from_int(Crunchy.parse("42540766411282592856903984951653826560"), 64).eq(setup().ip.network()));
116
+ assert.isOk(Ipv6.from_int(Crunchy.parse("42540766411282592856903984951653826560"), 64)!.eq(setup().ip.network()));
117
117
  });
118
118
  it("test_method_broadcast_u128", () => {
119
- assert.isOk(Ipv6.from_int(Crunchy.parse("42540766411282592875350729025363378175"), 64).eq(setup().ip.broadcast()));
119
+ assert.isOk(Ipv6.from_int(Crunchy.parse("42540766411282592875350729025363378175"), 64)!.eq(setup().ip.broadcast()));
120
120
  });
121
121
  it("test_method_size", () => {
122
122
  let ip = IPAddress.parse("2001:db8::8:800:200c:417a/64");
123
- assert.isOk(Crunchy.one().shl(64).eq(ip.size()));
123
+ assert.isOk(Crunchy.one().shl(64).eq(ip!.size()));
124
124
  ip = IPAddress.parse("2001:db8::8:800:200c:417a/32");
125
- assert.isOk(Crunchy.one().shl(96).eq(ip.size()));
125
+ assert.isOk(Crunchy.one().shl(96).eq(ip!.size()));
126
126
  ip = IPAddress.parse("2001:db8::8:800:200c:417a/120");
127
- assert.isOk(Crunchy.one().shl(8).eq(ip.size()));
127
+ assert.isOk(Crunchy.one().shl(8).eq(ip!.size()));
128
128
  ip = IPAddress.parse("2001:db8::8:800:200c:417a/124");
129
- assert.isOk(Crunchy.one().shl(4).eq(ip.size()));
129
+ assert.isOk(Crunchy.one().shl(4).eq(ip!.size()));
130
130
  });
131
131
  it("test_method_includes", () => {
132
132
  const ip = setup().ip;
@@ -134,18 +134,18 @@ describe("ipv6", () => {
134
134
  // test prefix on same address
135
135
  let included = IPAddress.parse("2001:db8::8:800:200c:417a/128");
136
136
  let not_included = IPAddress.parse("2001:db8::8:800:200c:417a/46");
137
- assert.equal(true, ip.includes(included));
138
- assert.equal(false, ip.includes(not_included));
137
+ assert.equal(true, ip.includes(included!));
138
+ assert.equal(false, ip.includes(not_included!));
139
139
  // test address on same prefix
140
140
  included = IPAddress.parse("2001:db8::8:800:200c:0/64");
141
141
  not_included = IPAddress.parse("2001:db8:1::8:800:200c:417a/64");
142
- assert.equal(true, ip.includes(included));
143
- assert.equal(false, ip.includes(not_included));
142
+ assert.equal(true, ip.includes(included!));
143
+ assert.equal(false, ip.includes(not_included!));
144
144
  // general test
145
145
  included = IPAddress.parse("2001:db8::8:800:200c:1/128");
146
146
  not_included = IPAddress.parse("2001:db8:1::8:800:200c:417a/76");
147
- assert.equal(true, ip.includes(included));
148
- assert.equal(false, ip.includes(not_included));
147
+ assert.equal(true, ip.includes(included!));
148
+ assert.equal(false, ip.includes(not_included!));
149
149
  });
150
150
  it("test_method_to_hex", () => {
151
151
  assert(setup().hex, setup().ip.to_hex());
@@ -162,14 +162,14 @@ describe("ipv6", () => {
162
162
  });
163
163
  it("test_method_reverse", () => {
164
164
  const str = "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa";
165
- assert.equal(str, IPAddress.parse("3ffe:505:2::f").dns_reverse());
165
+ assert.equal(str, IPAddress.parse("3ffe:505:2::f")!.dns_reverse());
166
166
  });
167
167
  it("test_method_dns_rev_domains", () => {
168
- assertArrayEqual(IPAddress.parse("f000:f100::/3").dns_rev_domains(), ["e.ip6.arpa", "f.ip6.arpa"]);
169
- assertArrayEqual(IPAddress.parse("fea3:f120::/15").dns_rev_domains(), ["2.a.e.f.ip6.arpa", "3.a.e.f.ip6.arpa"]);
170
- assertArrayEqual(IPAddress.parse("3a03:2f80:f::/48").dns_rev_domains(), ["f.0.0.0.0.8.f.2.3.0.a.3.ip6.arpa"]);
168
+ assertArrayEqual(IPAddress.parse("f000:f100::/3")!.dns_rev_domains(), ["e.ip6.arpa", "f.ip6.arpa"]);
169
+ assertArrayEqual(IPAddress.parse("fea3:f120::/15")!.dns_rev_domains(), ["2.a.e.f.ip6.arpa", "3.a.e.f.ip6.arpa"]);
170
+ assertArrayEqual(IPAddress.parse("3a03:2f80:f::/48")!.dns_rev_domains(), ["f.0.0.0.0.8.f.2.3.0.a.3.ip6.arpa"]);
171
171
 
172
- assertArrayEqual(IPAddress.parse("f000:f100::1234/125").dns_rev_domains(), [
172
+ assertArrayEqual(IPAddress.parse("f000:f100::1234/125")!.dns_rev_domains(), [
173
173
  "0.3.2.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.f.0.0.0.f.ip6.arpa",
174
174
  "1.3.2.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.f.0.0.0.f.ip6.arpa",
175
175
  "2.3.2.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.f.0.0.0.f.ip6.arpa",
@@ -181,21 +181,21 @@ describe("ipv6", () => {
181
181
  ]);
182
182
  });
183
183
  it("test_method_compressed", () => {
184
- assert.equal("1:1:1::1", IPAddress.parse("1:1:1:0:0:0:0:1").to_s());
185
- assert.equal("1:0:1::1", IPAddress.parse("1:0:1:0:0:0:0:1").to_s());
186
- assert.equal("1::1:1:1:2:3:1", IPAddress.parse("1:0:1:1:1:2:3:1").to_s());
187
- assert.equal("1::1:1:0:2:3:1", IPAddress.parse("1:0:1:1::2:3:1").to_s());
188
- assert.equal("1:0:0:1::1", IPAddress.parse("1:0:0:1:0:0:0:1").to_s());
189
- assert.equal("1::1:0:0:1", IPAddress.parse("1:0:0:0:1:0:0:1").to_s());
190
- assert.equal("1::1", IPAddress.parse("1:0:0:0:0:0:0:1").to_s());
184
+ assert.equal("1:1:1::1", IPAddress.parse("1:1:1:0:0:0:0:1")!.to_s());
185
+ assert.equal("1:0:1::1", IPAddress.parse("1:0:1:0:0:0:0:1")!.to_s());
186
+ assert.equal("1::1:1:1:2:3:1", IPAddress.parse("1:0:1:1:1:2:3:1")!.to_s());
187
+ assert.equal("1::1:1:0:2:3:1", IPAddress.parse("1:0:1:1::2:3:1")!.to_s());
188
+ assert.equal("1:0:0:1::1", IPAddress.parse("1:0:0:1:0:0:0:1")!.to_s());
189
+ assert.equal("1::1:0:0:1", IPAddress.parse("1:0:0:0:1:0:0:1")!.to_s());
190
+ assert.equal("1::1", IPAddress.parse("1:0:0:0:0:0:0:1")!.to_s());
191
191
  // assert.equal("1:1.1:2:0:0:1", IPAddress.parse("1:1:0:1:2.1").to_s
192
192
  });
193
193
  it("test_method_unspecified", () => {
194
- assert.equal(true, IPAddress.parse("::").is_unspecified());
194
+ assert.equal(true, IPAddress.parse("::")!.is_unspecified());
195
195
  assert.equal(false, setup().ip.is_unspecified());
196
196
  });
197
197
  it("test_method_loopback", () => {
198
- assert.equal(true, IPAddress.parse("::1").is_loopback());
198
+ assert.equal(true, IPAddress.parse("::1")!.is_loopback());
199
199
  assert.equal(false, setup().ip.is_loopback());
200
200
  });
201
201
  it("test_method_network", () => {
@@ -203,13 +203,13 @@ describe("ipv6", () => {
203
203
  const addr = i[0];
204
204
  const net = i[1];
205
205
  const ip = IPAddress.parse(addr);
206
- assert.equal(net, ip.network().to_string());
206
+ assert.equal(net, ip!.network().to_string());
207
207
  }
208
208
  });
209
209
  it("test_method_each", () => {
210
210
  const ip = IPAddress.parse("2001:db8::4/125");
211
211
  const arr: string[] = [];
212
- ip.each((i) => arr.push(i.to_s()));
212
+ ip!.each((i) => arr.push(i.to_s()));
213
213
  assertArrayEqual(arr, [
214
214
  "2001:db8::",
215
215
  "2001:db8::1",
@@ -242,24 +242,24 @@ describe("ipv6", () => {
242
242
  "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
243
243
  ];
244
244
  for (let prefix = 0; prefix < 128; ++prefix) {
245
- const nr_networks = 1 << (128 - prefix) % 4;
245
+ const nr_networks = 1 << ((128 - prefix) % 4);
246
246
  for (const adr of test_addrs) {
247
247
  const net_adr = IPAddress.parse(`${adr}/${prefix}`);
248
- const ret = net_adr.dns_networks();
248
+ const ret = net_adr!.dns_networks();
249
249
  assert.equal(ret[0].prefix.num % 4, 0);
250
250
  assert.equal(ret.length, nr_networks);
251
- assert.equal(net_adr.network().to_s(), ret[0].network().to_s());
252
- assert.equal(net_adr.broadcast().to_s(), ret[ret.length - 1].broadcast().to_s());
251
+ assert.equal(net_adr!.network().to_s(), ret[0].network().to_s());
252
+ assert.equal(net_adr!.broadcast().to_s(), ret[ret.length - 1].broadcast().to_s());
253
253
  // puts "//{adr}///{prefix} //{nr_networks} //{ret}"
254
254
  }
255
255
  }
256
256
  const ret0: string[] = [];
257
- for (const i of IPAddress.parse("fd01:db8::4/3").dns_networks()) {
257
+ for (const i of IPAddress.parse("fd01:db8::4/3")!.dns_networks()) {
258
258
  ret0.push(i.to_string());
259
259
  }
260
260
  assertArrayEqual(ret0, ["e000::/4", "f000::/4"]);
261
261
  const ret1: string[] = [];
262
- for (const i of IPAddress.parse("3a03:2f80:f::/48").dns_networks()) {
262
+ for (const i of IPAddress.parse("3a03:2f80:f::/48")!.dns_networks()) {
263
263
  ret1.push(i.to_string());
264
264
  }
265
265
  assertArrayEqual(ret1, ["3a03:2f80:f::/48"]);
@@ -271,26 +271,26 @@ describe("ipv6", () => {
271
271
  const ip4 = IPAddress.parse("2001:db8:1::1/65");
272
272
 
273
273
  // ip2 should be greater than ip1
274
- assert.equal(true, ip2.gt(ip1));
275
- assert.equal(false, ip1.gt(ip2));
276
- assert.equal(false, ip2.lt(ip1));
274
+ assert.equal(true, ip2!.gt(ip1!));
275
+ assert.equal(false, ip1!.gt(ip2!));
276
+ assert.equal(false, ip2!.lt(ip1!));
277
277
  // ip3 should be less than ip2
278
- assert.equal(true, ip2.gt(ip3));
279
- assert.equal(false, ip2.lt(ip3));
278
+ assert.equal(true, ip2!.gt(ip3!));
279
+ assert.equal(false, ip2!.lt(ip3!));
280
280
  // ip1 should be less than ip3
281
- assert.equal(true, ip1.lt(ip3));
282
- assert.equal(false, ip1.gt(ip3));
283
- assert.equal(false, ip3.lt(ip1));
281
+ assert.equal(true, ip1!.lt(ip3!));
282
+ assert.equal(false, ip1!.gt(ip3!));
283
+ assert.equal(false, ip3!.lt(ip1!));
284
284
  // ip1 should be equal to itself
285
- assert.equal(true, ip1.eq(ip1));
285
+ assert.equal(true, ip1!.eq(ip1!));
286
286
  // ip4 should be greater than ip1
287
- assert.equal(true, ip1.lt(ip4));
288
- assert.equal(false, ip1.gt(ip4));
287
+ assert.equal(true, ip1!.lt(ip4!));
288
+ assert.equal(false, ip1!.gt(ip4!));
289
289
  // test sorting
290
- const r = [ip1, ip2, ip3, ip4].sort((a, b) => a.cmp(b));
290
+ const r = [ip1, ip2, ip3, ip4].sort((a, b) => a!.cmp(b!));
291
291
  const ret: string[] = [];
292
292
  for (const i of r) {
293
- ret.push(i.to_string());
293
+ ret.push(i!.to_string());
294
294
  }
295
295
  assertArrayEqual(ret, ["2001:db8:1::1/64", "2001:db8:1::1/65", "2001:db8:1::2/64", "2001:db8:2::1/64"]);
296
296
  });
@@ -306,20 +306,20 @@ describe("ipv6", () => {
306
306
  it("test_classmethod_compress", () => {
307
307
  const compressed = "2001:db8:0:cd30::";
308
308
  const expanded = "2001:0db8:0000:cd30:0000:0000:0000:0000";
309
- assert.equal(compressed, IPAddress.parse(expanded).to_s());
310
- assert.equal("2001:db8::cd3", IPAddress.parse("2001:0db8:0::cd3").to_s());
311
- assert.equal("2001:db8::cd30", IPAddress.parse("2001:0db8::cd30").to_s());
312
- assert.equal("2001:db8::cd3", IPAddress.parse("2001:0db8::cd3").to_s());
309
+ assert.equal(compressed, IPAddress.parse(expanded)!.to_s());
310
+ assert.equal("2001:db8::cd3", IPAddress.parse("2001:0db8:0::cd3")!.to_s());
311
+ assert.equal("2001:db8::cd30", IPAddress.parse("2001:0db8::cd30")!.to_s());
312
+ assert.equal("2001:db8::cd3", IPAddress.parse("2001:0db8::cd3")!.to_s());
313
313
  });
314
314
  it("test_classhmethod_parse_u128", () => {
315
315
  for (const i of setup().valid_ipv6) {
316
316
  const ip = i[0];
317
317
  const num = i[1];
318
318
  // console.log(">>>>>>>>", i);
319
- assert.equal(IPAddress.parse(ip).to_s(), Ipv6.from_int(num, 128).to_s());
319
+ assert.equal(IPAddress.parse(ip)!.to_s(), Ipv6.from_int(num, 128)!.to_s());
320
320
  }
321
321
  });
322
322
  it("test_classmethod_parse_hex", () => {
323
- assert.equal(setup().ip.to_string(), Ipv6.from_str(setup().hex, 16, 64).to_string());
323
+ assert.equal(setup().ip.to_string(), Ipv6.from_str(setup().hex, 16, 64)!.to_string());
324
324
  });
325
325
  });
@@ -29,7 +29,7 @@ class IPv6LoopbackTest {
29
29
  describe("ipv6_loopback", () => {
30
30
  function setup(): IPv6LoopbackTest {
31
31
  return new IPv6LoopbackTest({
32
- ip: Ipv6Loopback.create(),
32
+ ip: Ipv6Loopback.create()!,
33
33
  s: "::1",
34
34
  n: "::1/128",
35
35
  string: "0000:0000:0000:0000:0000:0000:0000:0001/128",
@@ -36,7 +36,7 @@ class IPv6MappedTest {
36
36
  describe("ipv6_mapped", () => {
37
37
  function setup(): IPv6MappedTest {
38
38
  const ipv6 = new IPv6MappedTest({
39
- ip: Ipv6Mapped.create("::172.16.10.1"),
39
+ ip: Ipv6Mapped.create("::172.16.10.1")!,
40
40
  s: "::ffff:172.16.10.1",
41
41
  sstr: "::ffff:172.16.10.1/32",
42
42
  string: "0000:0000:0000:0000:0000:ffff:ac10:0a01/128",
@@ -66,21 +66,21 @@ describe("ipv6_mapped", () => {
66
66
  // console.log(IPAddress.parse(ip));
67
67
  }
68
68
  assert.isOk(IPAddress.parse(ip));
69
- assert.equal(u128.toString(), IPAddress.parse(ip).host_address.toString());
69
+ assert.equal(u128.toString(), IPAddress.parse(ip)!.host_address.toString());
70
70
  }
71
71
  for (const i of s.valid_mapped_ipv6) {
72
72
  const ip = i[0];
73
73
  const u128 = i[1];
74
74
  // println("===={}=={:x}", ip, u128);
75
75
  assert.isOk(IPAddress.parse(ip));
76
- assert.equal(u128.toString(), IPAddress.parse(ip).host_address.toString());
76
+ assert.equal(u128.toString(), IPAddress.parse(ip)!.host_address.toString());
77
77
  }
78
78
  });
79
79
  it("test_mapped_from_ipv6_conversion", () => {
80
80
  for (const i of setup().valid_mapped_ipv6_conversion) {
81
81
  const ip6 = i[0];
82
82
  const ip4 = i[1];
83
- assert.equal(ip4, IPAddress.parse(ip6).mapped.to_s());
83
+ assert.equal(ip4, IPAddress.parse(ip6)!.mapped!.to_s());
84
84
  }
85
85
  });
86
86
  it("test_attributes", () => {
@@ -29,7 +29,7 @@ class IPv6UnspecifiedTest {
29
29
  describe("ipv6_unspec", () => {
30
30
  function setup(): IPv6UnspecifiedTest {
31
31
  return new IPv6UnspecifiedTest({
32
- ip: Ipv6Unspec.create(),
32
+ ip: Ipv6Unspec.create()!,
33
33
  to_s: "::",
34
34
  to_string: "::/128",
35
35
  to_string_uncompressed: "0000:0000:0000:0000:0000:0000:0000:0000/128",
@@ -29,11 +29,11 @@ describe("prefix128", () => {
29
29
  for (let i = 0; i < 64; ++i) {
30
30
  str += "0";
31
31
  }
32
- assert.equal(str, prefix.bits());
32
+ assert.equal(str, prefix!.bits());
33
33
  });
34
34
  it("test_method_to_u32", () => {
35
35
  for (const hash of setup().u128_hash) {
36
- assert.isOk(hash[1].eq(Prefix128.create(hash[0]).netmask()));
36
+ assert.isOk(hash[1].eq(Prefix128.create(hash[0])!.netmask()));
37
37
  }
38
38
  });
39
39
  });
@@ -50,7 +50,7 @@ describe("prefix32", () => {
50
50
  it("test_attributes", () => {
51
51
  for (const e of setup().prefix_hash) {
52
52
  const prefix = Prefix32.create(e[1]);
53
- assert.equal(e[1], prefix.num);
53
+ assert.equal(e[1], prefix!.num);
54
54
  }
55
55
  });
56
56
 
@@ -68,36 +68,36 @@ describe("prefix32", () => {
68
68
  const netmask = hash[0];
69
69
  const num = hash[1];
70
70
  const prefix = Prefix32.create(num);
71
- assert.equal(netmask, prefix.to_ip_str());
71
+ assert.equal(netmask, prefix!.to_ip_str());
72
72
  }
73
73
  });
74
74
  it("test_method_to_s", () => {
75
75
  const prefix = Prefix32.create(8);
76
- assert.equal("8", prefix.to_s());
76
+ assert.equal("8", prefix!.to_s());
77
77
  });
78
78
  it("test_method_bits", () => {
79
79
  const prefix = Prefix32.create(16);
80
- assert.equal("11111111111111110000000000000000", prefix.bits());
80
+ assert.equal("11111111111111110000000000000000", prefix!.bits());
81
81
  });
82
82
  it("test_method_to_u32", () => {
83
83
  for (const i of setup().u32_hash) {
84
84
  const num = i[0];
85
85
  const ip32 = i[1];
86
- assert.isTrue(ip32.eq(Prefix32.create(num).netmask()));
86
+ assert.isTrue(ip32.eq(Prefix32.create(num)!.netmask()));
87
87
  }
88
88
  });
89
89
  it("test_method_plus", () => {
90
90
  const p1 = Prefix32.create(8);
91
91
  const p2 = Prefix32.create(10);
92
- assert.equal(18, p1.add_prefix(p2).num);
93
- assert.equal(12, p1.add(4).num);
92
+ assert.equal(18, p1!.add_prefix(p2!).num);
93
+ assert.equal(12, p1!.add(4).num);
94
94
  });
95
95
  it("test_method_minus", () => {
96
96
  const p1 = Prefix32.create(8);
97
97
  const p2 = Prefix32.create(24);
98
- assert.equal(16, p1.sub_prefix(p2).num);
99
- assert.equal(16, p2.sub_prefix(p1).num);
100
- assert.equal(20, p2.sub(4).num);
98
+ assert.equal(16, p1!.sub_prefix(p2!).num);
99
+ assert.equal(16, p2!.sub_prefix(p1!).num);
100
+ assert.equal(20, p2!.sub(4).num);
101
101
  });
102
102
  it("test_initialize", () => {
103
103
  assert.isNull(Prefix32.create(33));
@@ -108,7 +108,7 @@ describe("prefix32", () => {
108
108
  const arr = i[0];
109
109
  const pref = i[1];
110
110
  const prefix = Prefix32.create(pref);
111
- assertArrayEqual(prefix.ip_bits.parts(prefix.netmask()), arr);
111
+ assertArrayEqual(prefix!.ip_bits.parts(prefix!.netmask()), arr);
112
112
  }
113
113
  });
114
114
  it("test_method_brackets", () => {
@@ -118,13 +118,13 @@ describe("prefix32", () => {
118
118
  const prefix = Prefix32.create(pref);
119
119
  for (let index = 0; index < arr.length; ++index) {
120
120
  // console.log("xxxx", prefix.netmask());
121
- assert.equal(prefix.ip_bits.parts(prefix.netmask())[index], arr[index]);
121
+ assert.equal(prefix!.ip_bits.parts(prefix!.netmask())[index], arr[index]);
122
122
  }
123
123
  }
124
124
  });
125
125
  it("test_method_hostmask", () => {
126
126
  const prefix = Prefix32.create(8);
127
127
  // console.log(">>>>", prefix.host_mask());
128
- assert.equal("0.255.255.255", Ipv4.from_number(prefix.host_mask(), 0).to_s());
128
+ assert.equal("0.255.255.255", Ipv4.from_number(prefix!.host_mask(), 0)!.to_s());
129
129
  });
130
130
  });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=test_crunchy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test_crunchy.d.ts","sourceRoot":"","sources":["../../test/test_crunchy.ts"],"names":[],"mappings":""}