pmcf 1.37.1 → 1.37.2

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/utils.mjs +9 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.37.1",
3
+ "version": "1.37.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/utils.mjs CHANGED
@@ -82,17 +82,12 @@ function decodeIPv4(address, length = 32) {
82
82
  }
83
83
 
84
84
  export function encodeIPv6(address) {
85
- const words = [0, 0, 0, 0, 0, 0, 0, 0];
86
-
87
- let i = 0;
88
- for (const a of normalizeIPAddress(address).split(/\:/)) {
89
- words[i++] = parseInt(a,16);
90
- }
91
-
92
85
  let res = 0n;
93
86
  let shift = 128n;
94
87
 
95
- for(const word of words) {
88
+ for (const word of normalizeIPAddress(address)
89
+ .split(/\:/)
90
+ .map(a => parseInt(a, 16))) {
96
91
  shift -= 16n;
97
92
  res += BigInt(word) << shift;
98
93
  }
@@ -101,13 +96,12 @@ export function encodeIPv6(address) {
101
96
  }
102
97
 
103
98
  export function decodeIPv6(address, length = 128) {
104
-
105
99
  let words = [];
106
100
  let shift = 128n;
107
101
 
108
- for(let i = 0; i < length / 16; i++) {
102
+ for (let i = 0; i < length / 16; i++) {
109
103
  shift -= 16n;
110
- words[i] = ((address >> shift) & 0xffffn).toString(16).padStart(4,'0');
104
+ words.push(((address >> shift) & 0xffffn).toString(16).padStart(4, "0"));
111
105
  }
112
106
 
113
107
  return words.join(":");
@@ -127,7 +121,10 @@ export function normalizeCIDR(address) {
127
121
  prefix = decodeIPv4(n, prefixLength);
128
122
  } else {
129
123
  let n = encodeIPv6(prefix);
130
- n = n & (0xffffffffffffffffffffffffffffffffn << (128n - BigInt(prefixLength)));
124
+ n =
125
+ n &
126
+ (0xffffffffffffffffffffffffffffffffn <<
127
+ (128n - BigInt(prefixLength)));
131
128
  prefix = decodeIPv6(n, prefixLength);
132
129
  }
133
130
  } else {