ip-utilties 1.0.2 → 1.0.3
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.
- package/package.json +1 -1
- package/src/ip.mjs +3 -5
package/package.json
CHANGED
package/src/ip.mjs
CHANGED
|
@@ -181,7 +181,7 @@ function _is(definition, address) {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
export function asBigInt(address) {
|
|
184
|
-
return _asBigInt(
|
|
184
|
+
return _asBigInt(_definition(address), address);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
function _asBigInt(definition, address) {
|
|
@@ -207,7 +207,7 @@ function _encodeBigInt(definition, address) {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
export function prefixIP(address, length) {
|
|
210
|
-
const definition =
|
|
210
|
+
const definition = _definition(address);
|
|
211
211
|
return _decode(definition, _prefix(definition, address, length));
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -219,11 +219,9 @@ function _prefix(definition, address, length) {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
export function rangeIP(address, prefix, lowerAdd = 0, upperReduce = 0) {
|
|
222
|
-
const definition =
|
|
223
|
-
|
|
222
|
+
const definition = _definition(address);
|
|
224
223
|
const from = _prefix(definition, address, prefix);
|
|
225
224
|
const to = from | ((1n << BigInt(definition.bitLength - prefix)) - 1n);
|
|
226
|
-
|
|
227
225
|
return [
|
|
228
226
|
_encode(definition, from + BigInt(lowerAdd)),
|
|
229
227
|
_encode(definition, to - BigInt(upperReduce))
|