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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ip.mjs +3 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ip-utilties",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
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(isIPv4(address) ? ipv4 : ipv6, address);
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 = isIPv4(address) ? ipv4 : ipv6;
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 = isIPv4(address) ? ipv4 : ipv6;
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))