ipaddress 0.2.6 → 0.2.7

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
@@ -1,32 +1,34 @@
1
- import Crunchy from "../src/crunchy.js";
1
+ import { CrunchyWith32Bit } from "../src/crunchy.js";
2
+
3
+ const c32 = new CrunchyWith32Bit();
2
4
 
3
5
  describe("#compare", function () {
4
6
  it("Should confirm equality", function () {
5
- const x = Crunchy.from_string("12345678901234567890");
6
- const y = Crunchy.from_string("12345678901234567890");
7
- assert.isTrue(x.eq(y));
7
+ const x = c32.from_string("12345678901234567890");
8
+ const y = c32.from_string("12345678901234567890");
9
+ assert.isTrue(x!.eq(y!));
8
10
  // this.done();
9
11
  });
10
12
 
11
13
  it("Should find first is greater than second", function () {
12
- const x = Crunchy.from_string("12345678901234567890");
13
- const y = Crunchy.from_string("1234567890");
14
- assert.isTrue(x.gt(y));
14
+ const x = c32.from_string("12345678901234567890");
15
+ const y = c32.from_string("1234567890");
16
+ assert.isTrue(x!.gt(y!));
15
17
  // this.done();
16
18
  });
17
19
 
18
20
  it("Should find first is less than second", function () {
19
- const x = Crunchy.from_string("1234567890");
20
- const y = Crunchy.from_string("12345678901234567890");
21
- assert.isTrue(x.lt(y));
21
+ const x = c32.from_string("1234567890");
22
+ const y = c32.from_string("12345678901234567890");
23
+ assert.isTrue(x!.lt(y!));
22
24
  // this.done();
23
25
  });
24
26
  });
25
27
 
26
28
  describe("#add", function () {
27
29
  it("Should add numbers", function () {
28
- const x = Crunchy.from_8bit([242, 62]);
29
- const y = Crunchy.from_8bit([42, 2]);
30
+ const x = CrunchyWith32Bit.from_8bit([242, 62]);
31
+ const y = CrunchyWith32Bit.from_8bit([42, 2]);
30
32
 
31
33
  assert.deepEqual(x.add(y).to_8bit(), [1, 28, 64]);
32
34
  // x.should.eql([242, 62]);
@@ -34,8 +36,8 @@ describe("#add", function () {
34
36
  });
35
37
 
36
38
  it("Should add numbers, first longer than second", function () {
37
- const x = Crunchy.from_8bit([26, 255, 230, 17]);
38
- const y = Crunchy.from_8bit([42, 34]);
39
+ const x = CrunchyWith32Bit.from_8bit([26, 255, 230, 17]);
40
+ const y = CrunchyWith32Bit.from_8bit([42, 34]);
39
41
 
40
42
  assert.deepEqual(x.add(y).to_8bit(), [27, 0, 16, 51]);
41
43
 
@@ -44,8 +46,8 @@ describe("#add", function () {
44
46
  });
45
47
 
46
48
  it("Should add numbers, second longer than first", function () {
47
- const x = Crunchy.from_8bit([234, 34]);
48
- const y = Crunchy.from_8bit([255, 255, 230, 17]);
49
+ const x = CrunchyWith32Bit.from_8bit([234, 34]);
50
+ const y = CrunchyWith32Bit.from_8bit([255, 255, 230, 17]);
49
51
 
50
52
  assert.deepEqual(x.add(y).to_8bit(), [1, 0, 0, 208, 51]);
51
53
 
@@ -54,8 +56,8 @@ describe("#add", function () {
54
56
  });
55
57
 
56
58
  it("Should add two identical numbers", function () {
57
- const x = Crunchy.from_8bit([255, 255, 255, 255, 255, 255]);
58
- const y = Crunchy.from_8bit([255, 255, 255, 255, 255, 255]);
59
+ const x = CrunchyWith32Bit.from_8bit([255, 255, 255, 255, 255, 255]);
60
+ const y = CrunchyWith32Bit.from_8bit([255, 255, 255, 255, 255, 255]);
59
61
 
60
62
  assert.deepEqual(x.add(y).to_8bit(), [1, 255, 255, 255, 255, 255, 254]);
61
63
 
@@ -64,8 +66,8 @@ describe("#add", function () {
64
66
  });
65
67
 
66
68
  it("Should add positive to negative number expecting positive result", function () {
67
- const x = Crunchy.from_8bit([51, 254, 144, 207]);
68
- const y = Crunchy.from_8bit([-20, 89, 145, 32]);
69
+ const x = CrunchyWith32Bit.from_8bit([51, 254, 144, 207]);
70
+ const y = CrunchyWith32Bit.from_8bit([-20, 89, 145, 32]);
69
71
 
70
72
  assert.deepEqual(x.add(y).to_8bit(), [31, 164, 255, 175]);
71
73
 
@@ -74,8 +76,8 @@ describe("#add", function () {
74
76
  });
75
77
 
76
78
  it("Should add positive to negative number expecting negative result", function () {
77
- const x = Crunchy.from_8bit([242, 62]);
78
- const y = Crunchy.from_8bit([-242, 64]);
79
+ const x = CrunchyWith32Bit.from_8bit([242, 62]);
80
+ const y = CrunchyWith32Bit.from_8bit([-242, 64]);
79
81
 
80
82
  assert.deepEqual(x.add(y).to_8bit(), [-2]);
81
83
 
@@ -84,8 +86,8 @@ describe("#add", function () {
84
86
  });
85
87
 
86
88
  it("Should add negative to positive number expecting positive result", function () {
87
- const x = Crunchy.from_8bit([-42, 2]);
88
- const y = Crunchy.from_8bit([242, 62]);
89
+ const x = CrunchyWith32Bit.from_8bit([-42, 2]);
90
+ const y = CrunchyWith32Bit.from_8bit([242, 62]);
89
91
 
90
92
  assert.deepEqual(x.add(y).to_8bit(), [200, 60]);
91
93
 
@@ -94,8 +96,8 @@ describe("#add", function () {
94
96
  });
95
97
 
96
98
  it("Should add negative to positive number expecting negative result", function () {
97
- const x = Crunchy.from_8bit([-42, 2]);
98
- const y = Crunchy.from_8bit([42, 0]);
99
+ const x = CrunchyWith32Bit.from_8bit([-42, 2]);
100
+ const y = CrunchyWith32Bit.from_8bit([42, 0]);
99
101
 
100
102
  assert.deepEqual(x.add(y).to_8bit(), [-2]);
101
103
  // x, [-42, 2]);
@@ -103,8 +105,8 @@ describe("#add", function () {
103
105
  });
104
106
 
105
107
  it("Should add two negative numbers expecting negative result", function () {
106
- const x = Crunchy.from_8bit([-242, 62]);
107
- const y = Crunchy.from_8bit([-42, 2]);
108
+ const x = CrunchyWith32Bit.from_8bit([-242, 62]);
109
+ const y = CrunchyWith32Bit.from_8bit([-42, 2]);
108
110
 
109
111
  assert.deepEqual(x.add(y).to_8bit(), [-1, 28, 64]);
110
112
 
@@ -113,8 +115,8 @@ describe("#add", function () {
113
115
  });
114
116
 
115
117
  it("Should add zero to number", function () {
116
- const x = Crunchy.from_8bit([26, 255, 230, 17]);
117
- const y = Crunchy.from_8bit([0]);
118
+ const x = CrunchyWith32Bit.from_8bit([26, 255, 230, 17]);
119
+ const y = CrunchyWith32Bit.from_8bit([0]);
118
120
 
119
121
  assert.deepEqual(x.add(y).to_8bit(), [26, 255, 230, 17]);
120
122
 
@@ -123,8 +125,8 @@ describe("#add", function () {
123
125
  });
124
126
 
125
127
  it("Should add number to zero", function () {
126
- const x = Crunchy.from_8bit([0]);
127
- const y = Crunchy.from_8bit([43, 123, 200, 1]);
128
+ const x = CrunchyWith32Bit.from_8bit([0]);
129
+ const y = CrunchyWith32Bit.from_8bit([43, 123, 200, 1]);
128
130
 
129
131
  assert.deepEqual(x.add(y).to_8bit(), [43, 123, 200, 1]);
130
132
 
@@ -133,8 +135,8 @@ describe("#add", function () {
133
135
  });
134
136
 
135
137
  it("Should add two zeros", function () {
136
- const x = Crunchy.from_8bit([0]);
137
- const y = Crunchy.from_8bit([0]);
138
+ const x = CrunchyWith32Bit.from_8bit([0]);
139
+ const y = CrunchyWith32Bit.from_8bit([0]);
138
140
 
139
141
  assert.deepEqual(x.add(y).to_8bit(), [0]);
140
142
 
@@ -146,63 +148,63 @@ describe("#add", function () {
146
148
  describe("#add-from_string", function () {
147
149
  it("Should add numbers", function () {
148
150
  // console.log(new Date());
149
- const x = Crunchy.from_string("12345678911234567891");
151
+ const x = c32.from_string("12345678911234567891");
150
152
  // console.log(new Date());
151
- const y = Crunchy.from_string("12345678901234567890");
153
+ const y = c32.from_string("12345678901234567890");
152
154
  // console.log(new Date(), x, y);
153
155
  // console.log("addddddd:", new Date(), x, x.toString(), y, y.toString(), x.add(y).toString());
154
- assert.equal(x.add(y).toString(), "24691357812469135781");
156
+ assert.equal(x!.add(y!).toString(), "24691357812469135781");
155
157
  // console.log(new Date());
156
158
  // this.done();
157
159
  });
158
160
 
159
161
  it("Should add numbers, first longer than second", function () {
160
- const x = Crunchy.from_string("12345678901234567890");
161
- const y = Crunchy.from_string("1234567890");
162
- assert.equal(x.add(y).toString(), "12345678902469135780");
162
+ const x = c32.from_string("12345678901234567890");
163
+ const y = c32.from_string("1234567890");
164
+ assert.equal(x!.add(y!).toString(), "12345678902469135780");
163
165
  // this.done();
164
166
  });
165
167
 
166
168
  it("Should add numbers, second longer than first", function () {
167
- const x = Crunchy.from_string("1234567890");
168
- const y = Crunchy.from_string("12345678901234567890");
169
- assert.equal(x.add(y).toString(), "12345678902469135780");
169
+ const x = c32.from_string("1234567890");
170
+ const y = c32.from_string("12345678901234567890");
171
+ assert.equal(x!.add(y!).toString(), "12345678902469135780");
170
172
  // this.done();
171
173
  });
172
174
 
173
175
  it("Should add two identical numbers", function () {
174
- const x = Crunchy.from_string("12345678901234567890");
175
- const y = Crunchy.from_string("12345678901234567890");
176
- assert.equal(x.add(y).toString(), "24691357802469135780");
176
+ const x = c32.from_string("12345678901234567890");
177
+ const y = c32.from_string("12345678901234567890");
178
+ assert.equal(x!.add(y!).toString(), "24691357802469135780");
177
179
  // this.done();
178
180
  });
179
181
 
180
182
  it("Should add zero to number", function () {
181
- const x = Crunchy.from_string("12345678901234567890");
182
- const y = Crunchy.from_string("0");
183
- assert.equal(x.add(y).toString(), "12345678901234567890");
183
+ const x = c32.from_string("12345678901234567890");
184
+ const y = c32.from_string("0");
185
+ assert.equal(x!.add(y!).toString(), "12345678901234567890");
184
186
  // this.done();
185
187
  });
186
188
 
187
189
  it("Should add number to zero", function () {
188
- const x = Crunchy.from_string("0");
189
- const y = Crunchy.from_string("12345678901234567890");
190
- assert.equal(x.add(y).toString(), "12345678901234567890");
190
+ const x = c32.from_string("0");
191
+ const y = c32.from_string("12345678901234567890");
192
+ assert.equal(x!.add(y!).toString(), "12345678901234567890");
191
193
  // this.done();
192
194
  });
193
195
 
194
196
  it("Should add two zeros", function () {
195
- const x = Crunchy.from_string("0");
196
- const y = Crunchy.from_string("0");
197
- assert.equal(x.add(y).toString(), "0");
197
+ const x = c32.from_string("0");
198
+ const y = c32.from_string("0");
199
+ assert.equal(x!.add(y!).toString(), "0");
198
200
  // this.done();
199
201
  });
200
202
  });
201
203
 
202
204
  describe("#sub", function () {
203
205
  it("Should subtract numbers", function () {
204
- const x = Crunchy.from_8bit([170, 1, 79, 119, 242, 62]);
205
- const y = Crunchy.from_8bit([17, 241, 123, 250, 42, 2]);
206
+ const x = CrunchyWith32Bit.from_8bit([170, 1, 79, 119, 242, 62]);
207
+ const y = CrunchyWith32Bit.from_8bit([17, 241, 123, 250, 42, 2]);
206
208
 
207
209
  // console.log("Should subtract numbers:", x, y, x.sub(y));
208
210
  assert.deepEqual(x.sub(y).to_8bit(), [152, 15, 211, 125, 200, 60]);
@@ -211,8 +213,8 @@ describe("#sub", function () {
211
213
  });
212
214
 
213
215
  it("Should subtract one", function () {
214
- const x = Crunchy.from_8bit([240, 0, 0, 0, 0, 0]);
215
- const y = Crunchy.from_8bit([1]);
216
+ const x = CrunchyWith32Bit.from_8bit([240, 0, 0, 0, 0, 0]);
217
+ const y = CrunchyWith32Bit.from_8bit([1]);
216
218
 
217
219
  assert.deepEqual(x.sub(y).to_8bit(), [239, 255, 255, 255, 255, 255]);
218
220
 
@@ -221,8 +223,8 @@ describe("#sub", function () {
221
223
  });
222
224
 
223
225
  it("Should subtract numbers expecting negative result", function () {
224
- const x = Crunchy.from_8bit([26]);
225
- const y = Crunchy.from_8bit([255]);
226
+ const x = CrunchyWith32Bit.from_8bit([26]);
227
+ const y = CrunchyWith32Bit.from_8bit([255]);
226
228
 
227
229
  assert.deepEqual(x.sub(y).to_8bit(), [-229]);
228
230
 
@@ -231,8 +233,8 @@ describe("#sub", function () {
231
233
  });
232
234
 
233
235
  it("Should subtract numbers expecting negative result", function () {
234
- const x = Crunchy.from_8bit([188, 196]);
235
- const y = Crunchy.from_8bit([188, 197]);
236
+ const x = CrunchyWith32Bit.from_8bit([188, 196]);
237
+ const y = CrunchyWith32Bit.from_8bit([188, 197]);
236
238
 
237
239
  assert.deepEqual(x.sub(y).to_8bit(), [-1]);
238
240
 
@@ -241,8 +243,8 @@ describe("#sub", function () {
241
243
  });
242
244
 
243
245
  it("Should subtract negative number from positive", function () {
244
- const x = Crunchy.from_8bit([240, 0, 0, 0, 0, 0]);
245
- const y = Crunchy.from_8bit([-1]);
246
+ const x = CrunchyWith32Bit.from_8bit([240, 0, 0, 0, 0, 0]);
247
+ const y = CrunchyWith32Bit.from_8bit([-1]);
246
248
  // console.log("negative:", x, y, x.sub(y));
247
249
  assert.deepEqual(x.sub(y).to_8bit(), [240, 0, 0, 0, 0, 1]);
248
250
 
@@ -251,8 +253,8 @@ describe("#sub", function () {
251
253
  });
252
254
 
253
255
  it("Should subtract positive number from negative", function () {
254
- const x = Crunchy.from_8bit([-240, 0, 0, 0, 0, 0]);
255
- const y = Crunchy.from_8bit([1]);
256
+ const x = CrunchyWith32Bit.from_8bit([-240, 0, 0, 0, 0, 0]);
257
+ const y = CrunchyWith32Bit.from_8bit([1]);
256
258
 
257
259
  assert.deepEqual(x.sub(y).to_8bit(), [-240, 0, 0, 0, 0, 1]);
258
260
 
@@ -261,8 +263,8 @@ describe("#sub", function () {
261
263
  });
262
264
 
263
265
  it("Should subtract two negative numbers", function () {
264
- const x = Crunchy.from_8bit([-240, 0, 0, 0, 0, 0]);
265
- const y = Crunchy.from_8bit([-1]);
266
+ const x = CrunchyWith32Bit.from_8bit([-240, 0, 0, 0, 0, 0]);
267
+ const y = CrunchyWith32Bit.from_8bit([-1]);
266
268
 
267
269
  assert.deepEqual(x.sub(y).to_8bit(), [-239, 255, 255, 255, 255, 255]);
268
270
 
@@ -271,8 +273,8 @@ describe("#sub", function () {
271
273
  });
272
274
 
273
275
  it("Should subtract two equal numbers expecting zero", function () {
274
- const x = Crunchy.from_8bit([20]);
275
- const y = Crunchy.from_8bit([20]);
276
+ const x = CrunchyWith32Bit.from_8bit([20]);
277
+ const y = CrunchyWith32Bit.from_8bit([20]);
276
278
 
277
279
  assert.deepEqual(x.sub(y).to_8bit(), [0]);
278
280
 
@@ -281,8 +283,8 @@ describe("#sub", function () {
281
283
  });
282
284
 
283
285
  it("Should subtract zero", function () {
284
- const x = Crunchy.from_8bit([244, 137, 7, 161]);
285
- const y = Crunchy.from_8bit([0]);
286
+ const x = CrunchyWith32Bit.from_8bit([244, 137, 7, 161]);
287
+ const y = CrunchyWith32Bit.from_8bit([0]);
286
288
 
287
289
  assert.deepEqual(x.sub(y).to_8bit(), [244, 137, 7, 161]);
288
290
 
@@ -291,8 +293,8 @@ describe("#sub", function () {
291
293
  });
292
294
 
293
295
  it("Should subtract zero from zero", function () {
294
- const x = Crunchy.from_8bit([0]);
295
- const y = Crunchy.from_8bit([0]);
296
+ const x = CrunchyWith32Bit.from_8bit([0]);
297
+ const y = CrunchyWith32Bit.from_8bit([0]);
296
298
 
297
299
  assert.deepEqual(x.sub(y).to_8bit(), [0]);
298
300
 
@@ -301,8 +303,8 @@ describe("#sub", function () {
301
303
  });
302
304
 
303
305
  it("Should subtract from zero", function () {
304
- const x = Crunchy.from_8bit([0]);
305
- const y = Crunchy.from_8bit([15]);
306
+ const x = CrunchyWith32Bit.from_8bit([0]);
307
+ const y = CrunchyWith32Bit.from_8bit([15]);
306
308
 
307
309
  assert.deepEqual(x.sub(y).to_8bit(), [-15]);
308
310
 
@@ -313,64 +315,64 @@ describe("#sub", function () {
313
315
 
314
316
  describe("#mul", function () {
315
317
  it("Should multiply numbers", function () {
316
- const x = Crunchy.from_8bit([162, 51, 95]);
317
- const y = Crunchy.from_8bit([42, 18, 204]);
318
+ const x = CrunchyWith32Bit.from_8bit([162, 51, 95]);
319
+ const y = CrunchyWith32Bit.from_8bit([42, 18, 204]);
318
320
 
319
321
  assert.deepEqual(x.mul(y).to_8bit(), [26, 168, 86, 115, 157, 180]);
320
322
  });
321
323
 
322
324
  it("Should multiply numbers", function () {
323
- const x = Crunchy.from_8bit([255, 65, 34, 51, 95]);
324
- const y = Crunchy.from_8bit([42, 18, 204]);
325
+ const x = CrunchyWith32Bit.from_8bit([255, 65, 34, 51, 95]);
326
+ const y = CrunchyWith32Bit.from_8bit([42, 18, 204]);
325
327
 
326
328
  assert.deepEqual(x.mul(y).to_8bit(), [41, 243, 109, 152, 188, 115, 157, 180]);
327
329
  });
328
330
 
329
331
  it("Should multiply numbers", function () {
330
- const x = Crunchy.from_8bit([255, 255, 255, 255]);
331
- const y = Crunchy.from_8bit([255, 255, 255, 255]);
332
+ const x = CrunchyWith32Bit.from_8bit([255, 255, 255, 255]);
333
+ const y = CrunchyWith32Bit.from_8bit([255, 255, 255, 255]);
332
334
 
333
335
  assert.deepEqual(x.mul(y).to_8bit(), [255, 255, 255, 254, 0, 0, 0, 1]);
334
336
  });
335
337
 
336
338
  it("Should multiply positive with negative number", function () {
337
- const x = Crunchy.from_8bit([77, 242, 62]);
338
- const y = Crunchy.from_8bit([-42, 2, 113, 43, 57, 65]);
339
+ const x = CrunchyWith32Bit.from_8bit([77, 242, 62]);
340
+ const y = CrunchyWith32Bit.from_8bit([-42, 2, 113, 43, 57, 65]);
339
341
 
340
342
  assert.deepEqual(x.mul(y).to_8bit(), [-12, 202, 124, 133, 146, 125, 36, 79, 190]);
341
343
  });
342
344
 
343
345
  it("Should multiply negative with positive number", function () {
344
- const x = Crunchy.from_8bit([-255, 17, 162, 62]);
345
- const y = Crunchy.from_8bit([255, 17, 162, 62]);
346
+ const x = CrunchyWith32Bit.from_8bit([-255, 17, 162, 62]);
347
+ const y = CrunchyWith32Bit.from_8bit([255, 17, 162, 62]);
346
348
 
347
349
  assert.deepEqual(x.mul(y).to_8bit(), [-254, 36, 34, 110, 119, 14, 135, 4]);
348
350
  });
349
351
 
350
352
  it("Should multiply two negative numbers", function () {
351
- const x = Crunchy.from_8bit([-162, 51, 95]);
352
- const y = Crunchy.from_8bit([-42, 18, 204]);
353
+ const x = CrunchyWith32Bit.from_8bit([-162, 51, 95]);
354
+ const y = CrunchyWith32Bit.from_8bit([-42, 18, 204]);
353
355
 
354
356
  assert.deepEqual(x.mul(y).to_8bit(), [26, 168, 86, 115, 157, 180]);
355
357
  });
356
358
 
357
359
  it("Should multiply by zero", function () {
358
- const x = Crunchy.from_8bit([77, 242, 62]);
359
- const y = Crunchy.from_8bit([0]);
360
+ const x = CrunchyWith32Bit.from_8bit([77, 242, 62]);
361
+ const y = CrunchyWith32Bit.from_8bit([0]);
360
362
 
361
363
  assert.deepEqual(x.mul(y).to_8bit(), [0]);
362
364
  });
363
365
 
364
366
  it("Should multiply zero by number", function () {
365
- const x = Crunchy.from_8bit([0]);
366
- const y = Crunchy.from_8bit([77, 242, 62]);
367
+ const x = CrunchyWith32Bit.from_8bit([0]);
368
+ const y = CrunchyWith32Bit.from_8bit([77, 242, 62]);
367
369
 
368
370
  assert.deepEqual(x.mul(y).to_8bit(), [0]);
369
371
  });
370
372
 
371
373
  it("Should multiply zeros", function () {
372
- const x = Crunchy.from_8bit([0]);
373
- const y = Crunchy.from_8bit([0]);
374
+ const x = CrunchyWith32Bit.from_8bit([0]);
375
+ const y = CrunchyWith32Bit.from_8bit([0]);
374
376
 
375
377
  assert.deepEqual(x.mul(y).to_8bit(), [0]);
376
378
  });
@@ -378,174 +380,100 @@ describe("#mul", function () {
378
380
 
379
381
  describe("#div", function () {
380
382
  it("Should divide numbers", function () {
381
- const x = Crunchy.from_8bit([52, 155, 168, 23, 6, 85]);
382
- const y = Crunchy.from_8bit([19, 26, 247]);
383
+ const x = CrunchyWith32Bit.from_8bit([52, 155, 168, 23, 6, 85]);
384
+ const y = CrunchyWith32Bit.from_8bit([19, 26, 247]);
383
385
 
384
- assert.deepEqual(x.div(y).to_8bit(), [2, 192, 234, 136]);
386
+ assert.deepEqual(x.div(y)!.to_8bit(), [2, 192, 234, 136]);
385
387
  });
386
388
 
387
389
  it("Should divide by one", function () {
388
- const x = Crunchy.from_8bit([15, 127, 73, 1]);
389
- const y = Crunchy.from_8bit([1]);
390
+ const x = CrunchyWith32Bit.from_8bit([15, 127, 73, 1]);
391
+ const y = CrunchyWith32Bit.from_8bit([1]);
390
392
 
391
- assert.deepEqual(x.div(y).to_8bit(), [15, 127, 73, 1]);
393
+ assert.deepEqual(x.div(y)!.to_8bit(), [15, 127, 73, 1]);
392
394
  });
393
395
 
394
396
  it("Should divide by self", function () {
395
- const x = Crunchy.from_8bit([15, 127, 73, 1]);
396
- const y = Crunchy.from_8bit([15, 127, 73, 1]);
397
+ const x = CrunchyWith32Bit.from_8bit([15, 127, 73, 1]);
398
+ const y = CrunchyWith32Bit.from_8bit([15, 127, 73, 1]);
397
399
 
398
- assert.deepEqual(x.div(y).to_8bit(), [1]);
400
+ assert.deepEqual(x.div(y)!.to_8bit(), [1]);
399
401
  });
400
402
 
401
403
  it("Should divide negative number", function () {
402
- const x = Crunchy.from_8bit([-170, 153, 136]);
403
- const y = Crunchy.from_8bit([17, 68]);
404
+ const x = CrunchyWith32Bit.from_8bit([-170, 153, 136]);
405
+ const y = CrunchyWith32Bit.from_8bit([17, 68]);
404
406
 
405
- assert.deepEqual(x.div(y).to_8bit(), [-9, 225]);
407
+ assert.deepEqual(x.div(y)!.to_8bit(), [-9, 225]);
406
408
  });
407
409
 
408
410
  it("Should divide by negative number", function () {
409
- const x = Crunchy.from_8bit([170, 153, 136, 119, 102, 85]);
410
- const y = Crunchy.from_8bit([-17, 68]);
411
+ const x = CrunchyWith32Bit.from_8bit([170, 153, 136, 119, 102, 85]);
412
+ const y = CrunchyWith32Bit.from_8bit([-17, 68]);
411
413
 
412
- assert.deepEqual(x.div(y).to_8bit(), [-9, 225, 129, 255, 9]);
414
+ assert.deepEqual(x.div(y)!.to_8bit(), [-9, 225, 129, 255, 9]);
413
415
  });
414
416
 
415
417
  it("Should divide two negative numbers", function () {
416
- const x = Crunchy.from_8bit([-52, 155, 168, 23, 6, 85]);
417
- const y = Crunchy.from_8bit([-19, 26, 247]);
418
+ const x = CrunchyWith32Bit.from_8bit([-52, 155, 168, 23, 6, 85]);
419
+ const y = CrunchyWith32Bit.from_8bit([-19, 26, 247]);
418
420
 
419
- assert.deepEqual(x.div(y).to_8bit(), [2, 192, 234, 136]);
421
+ assert.deepEqual(x.div(y)!.to_8bit(), [2, 192, 234, 136]);
420
422
  });
421
423
 
422
424
  it("Should divide zero", function () {
423
- const x = Crunchy.from_8bit([0]);
424
- const y = Crunchy.from_8bit([17, 68]);
425
+ const x = CrunchyWith32Bit.from_8bit([0]);
426
+ const y = CrunchyWith32Bit.from_8bit([17, 68]);
425
427
 
426
- assert.deepEqual(x.div(y).to_8bit(), [0]);
428
+ assert.deepEqual(x.div(y)!.to_8bit(), [0]);
427
429
  });
428
430
 
429
431
  it("Shouldn't divide by zero", function () {
430
- const x = Crunchy.from_8bit([170, 153]);
431
- const y = Crunchy.from_8bit([0]);
432
+ const x = CrunchyWith32Bit.from_8bit([170, 153]);
433
+ const y = CrunchyWith32Bit.from_8bit([0]);
432
434
 
433
435
  assert.isNotOk(x.div(y));
434
436
  });
435
437
 
436
438
  it("Shouldn't divide zero by zero", function () {
437
- const x = Crunchy.from_8bit([0]);
438
- const y = Crunchy.from_8bit([0]);
439
+ const x = CrunchyWith32Bit.from_8bit([0]);
440
+ const y = CrunchyWith32Bit.from_8bit([0]);
439
441
 
440
442
  assert.isNotOk(x.div(y));
441
443
  });
442
444
  });
443
445
 
444
- // describe("#mod", function() {
445
-
446
- // it("Should calculate modulo", function() {
447
- // let x = [52, 155, 168, 23, 6, 85],
448
- // y = [19, 26, 247];
449
-
450
- // Crunch.mod(x, y).should.eql([10, 237, 29]);
451
-
452
- // x.should.eql([52, 155, 168, 23, 6, 85]);
453
- // y.should.eql([19, 26, 247]);
454
- // });
455
-
456
- // it("Should calculate modulo of number smaller than modulus", function() {
457
- // let x = [1, 0],
458
- // y = [1, 241];
459
-
460
- // Crunch.mod(x, y).should.eql([1, 0]);
461
-
462
- // x.should.eql([1, 0]);
463
- // y.should.eql([1, 241]);
464
- // });
465
-
466
- // it("Should calculate modulo of modulus", function() {
467
- // let x = [1, 241],
468
- // y = [1, 241];
469
-
470
- // Crunch.mod(x, y).should.eql([0]);
471
-
472
- // x.should.eql([1, 241]);
473
- // y.should.eql([1, 241]);
474
- // });
475
-
476
- // it("Should calculate modulo of zero", function() {
477
- // let x = [0],
478
- // y = [1, 241];
479
-
480
- // Crunch.mod(x, y).should.eql([0]);
481
-
482
- // x.should.eql([0]);
483
- // y.should.eql([1, 241]);
484
- // });
485
-
486
- // // it("Should calculate modulo of negative", function() {
487
- // // let x = [-4],
488
- // // y = [3];
489
-
490
- // // Crunch.mod(x, y).should.eql([2]);
491
-
492
- // // x.should.eql([-4]);
493
- // // y.should.eql([3]);
494
- // // });
495
-
496
- // // it("Should calculate modulo of negative", function() {
497
- // // let x = [ -10, 18 ],
498
- // // y = [ 123 ];
499
-
500
- // // Crunch.mod(x, y).should.eql([ 5 ]);
501
-
502
- // // x.should.eql([ -10, 18 ]);
503
- // // y.should.eql([ 123 ]);
504
- // // });
505
-
506
- // // it("Should calculate modulo of negative", function() {
507
- // // let x = [ -15, 62, 62, 18, 176 ],
508
- // // y = [ 139, 207, 194, 82 ];
509
-
510
- // // Crunch.mod(x, y).should.eql([ 12, 123, 46, 72 ]);
511
-
512
- // // x.should.eql([ -15, 62, 62, 18, 176 ]);
513
- // // y.should.eql([ 139, 207, 194, 82 ]);
514
- // // });
515
-
516
- // });
517
-
518
446
  describe("#leftShift", function () {
519
447
  it("Should left shift a number", function () {
520
- const x = Crunchy.from_8bit([22, 11]);
448
+ const x = CrunchyWith32Bit.from_8bit([22, 11]);
521
449
  const s = 5;
522
450
 
523
451
  assert.deepEqual(x.shl(s).to_8bit(), [2, 193, 96]);
524
452
  });
525
453
 
526
454
  it("Should left shift a number more", function () {
527
- const x = Crunchy.from_8bit([1]);
455
+ const x = CrunchyWith32Bit.from_8bit([1]);
528
456
  const s = 64;
529
457
 
530
458
  assert.deepEqual(x.shl(s).to_8bit(), [1, 0, 0, 0, 0, 0, 0, 0, 0]);
531
459
  });
532
460
 
533
461
  it("Should left shift zero", function () {
534
- const x = Crunchy.from_8bit([0]);
462
+ const x = CrunchyWith32Bit.from_8bit([0]);
535
463
  const s = 80;
536
464
 
537
465
  assert.deepEqual(x.shl(s).to_8bit(), [0]);
538
466
  });
539
467
 
540
468
  it("Should left shift negative", function () {
541
- const x = Crunchy.from_8bit([-3]);
469
+ const x = CrunchyWith32Bit.from_8bit([-3]);
542
470
  const s = 8;
543
471
 
544
472
  assert.deepEqual(x.shl(s).to_8bit(), [-3, 0]);
545
473
  });
546
474
 
547
475
  it("Should left shift one", function () {
548
- const x = Crunchy.from_8bit([1, 0, 0, 0, 0]);
476
+ const x = CrunchyWith32Bit.from_8bit([1, 0, 0, 0, 0]);
549
477
  const s = 1;
550
478
 
551
479
  assert.deepEqual(x.shl(s).to_8bit(), [2, 0, 0, 0, 0]);
@@ -554,61 +482,29 @@ describe("#leftShift", function () {
554
482
 
555
483
  describe("#rightShift", function () {
556
484
  it("Should right shift a number to zero", function () {
557
- const x = Crunchy.from_14bit([167837953]);
485
+ const x = CrunchyWith32Bit.from_14bit([167837953]);
558
486
  // assert.deepEqual(x.rsh(32).num, [0]);
559
487
  assert.deepEqual(x.shr(32).num, [0]);
560
488
  assert.deepEqual(x.shr(33).num, [0]);
561
489
  });
562
490
 
563
491
  it("Should right shift a number", function () {
564
- const x = Crunchy.from_8bit([22, 11]);
492
+ const x = CrunchyWith32Bit.from_8bit([22, 11]);
565
493
  const s = 5;
566
494
 
567
495
  assert.deepEqual(x.shr(s).to_8bit(), [176]);
568
496
  });
569
497
 
570
498
  it("Should right shift a number out of existance", function () {
571
- const x = Crunchy.from_8bit([22, 11]);
499
+ const x = CrunchyWith32Bit.from_8bit([22, 11]);
572
500
  const s = 20;
573
501
 
574
502
  assert.deepEqual(x.shr(s).to_8bit(), [0]);
575
503
  });
576
504
 
577
505
  it("Should right shift a negative number", function () {
578
- const x = Crunchy.from_8bit([-3]);
506
+ const x = CrunchyWith32Bit.from_8bit([-3]);
579
507
  const s = 8;
580
508
  assert.deepEqual(x.shr(s).to_8bit(), [-0]);
581
509
  });
582
510
  });
583
-
584
- // describe("#parse", function() {
585
-
586
- // it("Should convert string to integer", function() {
587
- // let s = "6315359056060240643798024";
588
-
589
- // Crunchy.parse(s).to_8bit().should.eql([5, 57, 84, 76, 233, 0, 120, 91, 180, 180, 8]);
590
-
591
- // s.should.equal("6315359056060240643798024");
592
- // });
593
-
594
- // it("Should convert string negative number to integer", function() {
595
- // let s = "-256";
596
-
597
- // Crunchy.parse(s).to_8bit().should.eql([-1, 0]);
598
-
599
- // s.should.equal("-256");
600
- // });
601
-
602
- // });
603
-
604
- // describe("#stringify", function() {
605
-
606
- // it("Should convert integer to string", function() {
607
- // let x = [5, 57, 84, 76, 233, 0, 120, 91, 180, 180, 8];
608
-
609
- // Crunchy.from_8bit(x).to_8bit().should.equal("6315359056060240643798024");
610
-
611
- // x.should.eql([5, 57, 84, 76, 233, 0, 120, 91, 180, 180, 8]);
612
- // });
613
-
614
- // });