ipaddress 0.2.5 → 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 (118) hide show
  1. package/dist/src/crunchy.d.ts +130 -0
  2. package/dist/src/crunchy.d.ts.map +1 -0
  3. package/dist/src/crunchy.js +616 -0
  4. package/dist/src/index.d.ts +13 -0
  5. package/dist/src/index.d.ts.map +1 -0
  6. package/dist/src/index.js +21 -0
  7. package/{ip_bits.d.ts → dist/src/ip_bits.d.ts} +6 -7
  8. package/dist/src/ip_bits.d.ts.map +1 -0
  9. package/dist/src/ip_bits.js +133 -0
  10. package/{ip_version.d.ts → dist/src/ip_version.d.ts} +2 -1
  11. package/dist/src/ip_version.d.ts.map +1 -0
  12. package/dist/src/ip_version.js +6 -0
  13. package/{ipaddress.d.ts → dist/src/ipaddress.d.ts} +38 -35
  14. package/dist/src/ipaddress.d.ts.map +1 -0
  15. package/dist/src/ipaddress.js +1243 -0
  16. package/dist/src/ipv4.d.ts +15 -0
  17. package/dist/src/ipv4.d.ts.map +1 -0
  18. package/dist/src/ipv4.js +187 -0
  19. package/dist/src/ipv6.d.ts +13 -0
  20. package/dist/src/ipv6.d.ts.map +1 -0
  21. package/dist/src/ipv6.js +190 -0
  22. package/dist/src/ipv6_loopback.d.ts +6 -0
  23. package/dist/src/ipv6_loopback.d.ts.map +1 -0
  24. package/dist/src/ipv6_loopback.js +51 -0
  25. package/dist/src/ipv6_mapped.d.ts +6 -0
  26. package/dist/src/ipv6_mapped.d.ts.map +1 -0
  27. package/dist/src/ipv6_mapped.js +159 -0
  28. package/dist/src/ipv6_unspec.d.ts +6 -0
  29. package/dist/src/ipv6_unspec.d.ts.map +1 -0
  30. package/dist/src/ipv6_unspec.js +57 -0
  31. package/{prefix.d.ts → dist/src/prefix.d.ts} +10 -7
  32. package/dist/src/prefix.d.ts.map +1 -0
  33. package/dist/src/prefix.js +142 -0
  34. package/dist/src/prefix128.d.ts +7 -0
  35. package/dist/src/prefix128.d.ts.map +1 -0
  36. package/dist/src/prefix128.js +39 -0
  37. package/dist/src/prefix32.d.ts +7 -0
  38. package/dist/src/prefix32.d.ts.map +1 -0
  39. package/dist/src/prefix32.js +29 -0
  40. package/dist/src/rle.d.ts +19 -0
  41. package/dist/src/rle.d.ts.map +1 -0
  42. package/dist/src/rle.js +73 -0
  43. package/dist/test/test_crunchy_impls.d.ts +2 -0
  44. package/dist/test/test_crunchy_impls.d.ts.map +1 -0
  45. package/dist/test/test_crunchy_impls.js +150 -0
  46. package/dist/test/test_crunchy_with32bit.d.ts +2 -0
  47. package/dist/test/test_crunchy_with32bit.d.ts.map +1 -0
  48. package/dist/test/test_crunchy_with32bit.js +382 -0
  49. package/dist/test/test_ipaddress.d.ts +2 -0
  50. package/dist/test/test_ipaddress.d.ts.map +1 -0
  51. package/dist/test/test_ipaddress.js +182 -0
  52. package/dist/test/test_ipv4.d.ts +2 -0
  53. package/dist/test/test_ipv4.d.ts.map +1 -0
  54. package/dist/test/test_ipv4.js +561 -0
  55. package/dist/test/test_ipv6.d.ts +2 -0
  56. package/dist/test/test_ipv6.d.ts.map +1 -0
  57. package/dist/test/test_ipv6.js +313 -0
  58. package/dist/test/test_ipv6_loopback.d.ts +2 -0
  59. package/dist/test/test_ipv6_loopback.d.ts.map +1 -0
  60. package/dist/test/test_ipv6_loopback.js +40 -0
  61. package/dist/test/test_ipv6_mapped.d.ts +2 -0
  62. package/dist/test/test_ipv6_mapped.d.ts.map +1 -0
  63. package/dist/test/test_ipv6_mapped.js +89 -0
  64. package/dist/test/test_ipv6_unspec.d.ts +2 -0
  65. package/dist/test/test_ipv6_unspec.d.ts.map +1 -0
  66. package/dist/test/test_ipv6_unspec.js +39 -0
  67. package/dist/test/test_prefix128.d.ts +2 -0
  68. package/dist/test/test_prefix128.d.ts.map +1 -0
  69. package/dist/test/test_prefix128.js +35 -0
  70. package/dist/test/test_prefix32.d.ts +2 -0
  71. package/dist/test/test_prefix32.d.ts.map +1 -0
  72. package/dist/test/test_prefix32.js +126 -0
  73. package/dist/test/test_rle.d.ts +2 -0
  74. package/dist/test/test_rle.d.ts.map +1 -0
  75. package/dist/test/test_rle.js +141 -0
  76. package/dist/vitest.config.d.ts +3 -0
  77. package/dist/vitest.config.d.ts.map +1 -0
  78. package/dist/vitest.config.js +11 -0
  79. package/package.json +41 -37
  80. package/src/crunchy.ts +731 -0
  81. package/src/index.ts +23 -0
  82. package/src/ip_bits.ts +148 -0
  83. package/src/ip_version.ts +6 -0
  84. package/src/ipaddress.ts +1347 -0
  85. package/src/ipv4.ts +203 -0
  86. package/src/ipv6.ts +202 -0
  87. package/src/ipv6_loopback.ts +55 -0
  88. package/src/ipv6_mapped.ts +163 -0
  89. package/src/ipv6_unspec.ts +59 -0
  90. package/src/prefix.ts +170 -0
  91. package/src/prefix128.ts +42 -0
  92. package/src/prefix32.ts +32 -0
  93. package/src/rle.ts +85 -0
  94. package/test/test_crunchy_impls.ts +179 -0
  95. package/test/test_crunchy_with32bit.ts +510 -0
  96. package/test/test_ipaddress.ts +208 -0
  97. package/test/test_ipv4.ts +596 -0
  98. package/test/test_ipv6.ts +325 -0
  99. package/test/test_ipv6_loopback.ts +52 -0
  100. package/test/test_ipv6_mapped.ts +101 -0
  101. package/test/test_ipv6_unspec.ts +51 -0
  102. package/test/test_prefix128.ts +39 -0
  103. package/test/test_prefix32.ts +130 -0
  104. package/test/test_rle.ts +144 -0
  105. package/LICENSE +0 -20
  106. package/README.md +0 -960
  107. package/crunchy.d.ts +0 -55
  108. package/index.d.ts +0 -12
  109. package/ipaddress.js +0 -2869
  110. package/ipaddress.js.map +0 -1
  111. package/ipv4.d.ts +0 -14
  112. package/ipv6.d.ts +0 -12
  113. package/ipv6_loopback.d.ts +0 -5
  114. package/ipv6_mapped.d.ts +0 -5
  115. package/ipv6_unspec.d.ts +0 -5
  116. package/prefix128.d.ts +0 -6
  117. package/prefix32.d.ts +0 -6
  118. package/rle.d.ts +0 -14
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Arbitrary-precision integer used throughout ip address math.
3
+ *
4
+ * Historically this was always the hand-rolled 28-bit-limb
5
+ * implementation below (CrunchyWith32Bit), ported from
6
+ * Crunch - Arbitrary-precision integer arithmetic library
7
+ * Copyright (C) 2014 Nenad Vukicevic crunch.secureroom.net/license
8
+ *
9
+ * Native BigInt is now available in every runtime this library
10
+ * targets, so there are two implementations of CrunchyBase -
11
+ * CrunchyWithBigInt (native BigInt, used whenever available) and
12
+ * CrunchyWith32Bit (the original limb-array implementation, kept for
13
+ * environments without BigInt support). Which one backs `Crunchy` is
14
+ * decided once, at module load, by feature-detecting BigInt.
15
+ *
16
+ * `Crunchy` is a value (not a class), so `new Crunchy()` is not
17
+ * possible - use `Crunchy.create()` (or any of the other factories:
18
+ * `Crunchy.zero()`, `Crunchy.parse()`, ...).
19
+ */
20
+ export interface CrunchyBase {
21
+ clone(): CrunchyBase;
22
+ compare(y: CrunchyBase): number;
23
+ eq(oth: CrunchyBase): boolean;
24
+ lt(oth: CrunchyBase): boolean;
25
+ lte(oth: CrunchyBase): boolean;
26
+ gt(oth: CrunchyBase): boolean;
27
+ gte(oth: CrunchyBase): boolean;
28
+ add(y: CrunchyBase): CrunchyBase;
29
+ sub(y: CrunchyBase): CrunchyBase;
30
+ shl(s: number): CrunchyBase;
31
+ shr(s: number): CrunchyBase;
32
+ mod(y: CrunchyBase): CrunchyBase;
33
+ toString(radix?: number): string;
34
+ create(value?: number | string): CrunchyBase;
35
+ zero(): CrunchyBase;
36
+ one(): CrunchyBase;
37
+ two(): CrunchyBase;
38
+ parse(val: string): CrunchyBase;
39
+ from_number(val: number): CrunchyBase;
40
+ from_string(val: string, radix?: number): CrunchyBase | null;
41
+ from_string_or_throw(val: string, radix?: number): CrunchyBase;
42
+ }
43
+ /**
44
+ * Native BigInt-backed implementation. Used whenever the runtime
45
+ * supports BigInt (i.e. essentially always: Node 10.4+, every
46
+ * evergreen browser, Deno).
47
+ */
48
+ export declare class CrunchyWithBigInt implements CrunchyBase {
49
+ readonly value: bigint;
50
+ private constructor();
51
+ static bootstrap(): CrunchyWithBigInt;
52
+ private static valueOf;
53
+ clone(): CrunchyBase;
54
+ compare(y: CrunchyBase): number;
55
+ eq(oth: CrunchyBase): boolean;
56
+ lt(oth: CrunchyBase): boolean;
57
+ lte(oth: CrunchyBase): boolean;
58
+ gt(oth: CrunchyBase): boolean;
59
+ gte(oth: CrunchyBase): boolean;
60
+ add(y: CrunchyBase): CrunchyBase;
61
+ sub(y: CrunchyBase): CrunchyBase;
62
+ shl(s: number): CrunchyBase;
63
+ shr(s: number): CrunchyBase;
64
+ mod(y: CrunchyBase): CrunchyBase;
65
+ toString(radix?: number): string;
66
+ create(value?: number | string): CrunchyBase;
67
+ zero(): CrunchyBase;
68
+ one(): CrunchyBase;
69
+ two(): CrunchyBase;
70
+ parse(val: string): CrunchyBase;
71
+ from_number(val: number): CrunchyBase;
72
+ from_string(val: string, radix?: number): CrunchyBase | null;
73
+ from_string_or_throw(val: string, radix?: number): CrunchyBase;
74
+ }
75
+ /**
76
+ * @module Crunch
77
+ * Radix: 28 bits
78
+ * Endianness: Big
79
+ *
80
+ * @param {boolean} rawIn - expect 28-bit arrays
81
+ * @param {boolean} rawOut - return 28-bit arrays
82
+ */
83
+ export declare class CrunchyWith32Bit implements CrunchyBase {
84
+ num: number[];
85
+ negative: boolean;
86
+ static zeroes: number[];
87
+ clone(): CrunchyWith32Bit;
88
+ static removeLeadingZeros(inn: number[]): number[];
89
+ static from_14bit(a: number[]): CrunchyWith32Bit;
90
+ static from_8bit(a: number[]): CrunchyWith32Bit;
91
+ private static _zero;
92
+ private static _one;
93
+ private static _two;
94
+ create(value?: number | string): CrunchyBase;
95
+ zero(): CrunchyBase;
96
+ one(): CrunchyBase;
97
+ two(): CrunchyBase;
98
+ parse(val: string): CrunchyWith32Bit;
99
+ from_number(val: number): CrunchyWith32Bit;
100
+ from_string_or_throw(val: string, radix?: number): CrunchyWith32Bit;
101
+ from_string(val: string, radix?: number): CrunchyWith32Bit | null;
102
+ to_8bit(): number[];
103
+ compare(y: CrunchyBase): number;
104
+ eq(oth: CrunchyBase): boolean;
105
+ lt(oth: CrunchyBase): boolean;
106
+ lte(oth: CrunchyBase): boolean;
107
+ gt(oth: CrunchyBase): boolean;
108
+ gte(oth: CrunchyBase): boolean;
109
+ add(y: CrunchyBase): CrunchyWith32Bit;
110
+ unsigned_add(_y: CrunchyWith32Bit): CrunchyWith32Bit;
111
+ sub(y: CrunchyBase): CrunchyWith32Bit;
112
+ unsigned_sub(_y: CrunchyWith32Bit, internal?: boolean): CrunchyWith32Bit;
113
+ lsh(s: number): CrunchyWith32Bit;
114
+ rsh(s: number): CrunchyWith32Bit;
115
+ mul(y: CrunchyBase): CrunchyWith32Bit;
116
+ static msb(x: number): number | undefined;
117
+ shr(s: number): CrunchyWith32Bit;
118
+ shl(s: number): CrunchyWith32Bit;
119
+ cut(): CrunchyWith32Bit;
120
+ div(y: CrunchyBase, internal?: boolean): CrunchyWith32Bit | null;
121
+ div_or_throw(y: CrunchyBase, internal?: boolean): CrunchyWith32Bit;
122
+ mod(y: CrunchyBase): CrunchyWith32Bit;
123
+ mds(n: number): number;
124
+ toString(radix?: number): string;
125
+ }
126
+ export declare const hasBigInt: boolean;
127
+ export type Crunchy = CrunchyBase;
128
+ export declare const Crunchy: CrunchyBase;
129
+ export default Crunchy;
130
+ //# sourceMappingURL=crunchy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crunchy.d.ts","sourceRoot":"","sources":["../../src/crunchy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,WAAW;IAC1B,KAAK,IAAI,WAAW,CAAC;IACrB,OAAO,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAChC,EAAE,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC;IAC9B,EAAE,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC;IAC9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