@polkadot/types-codec 8.8.2-1 → 8.8.3-0

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.
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@polkadot/types-codec',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '8.8.2-1'
14
+ version: '8.8.3-0'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
@@ -76,12 +76,14 @@ function alias(src, dest) {
76
76
 
77
77
  function cleanupCompact() {
78
78
  return value => {
79
- for (let index = 0; index < value.length; index++) {
80
- if (value[index] === '<') {
81
- const end = findClosing(value, index + 1) - 14;
82
-
83
- if (value.substring(end, end + 14) === ' as HasCompact') {
84
- value = `Compact<${value.substring(index + 1, end)}>`;
79
+ if (value.includes(' as HasCompact')) {
80
+ for (let index = 0; index < value.length; index++) {
81
+ if (value[index] === '<') {
82
+ const end = findClosing(value, index + 1) - 14;
83
+
84
+ if (value.substring(end, end + 14) === ' as HasCompact') {
85
+ value = `Compact<${value.substring(index + 1, end)}>`;
86
+ }
85
87
  }
86
88
  }
87
89
  }
@@ -119,15 +121,22 @@ function replaceTagWith(value, matcher, replacer) {
119
121
 
120
122
 
121
123
  function removeExtensions(type, isSized) {
122
- return value => BOUNDED.reduce((value, tag) => replaceTagWith(value, `${type}${tag}<`, inner => {
123
- const parts = inner.split(',').map(s => s.trim()).filter(s => s);
124
+ return value => {
125
+ for (let i = 0; i < BOUNDED.length; i++) {
126
+ const tag = BOUNDED[i];
127
+ value = replaceTagWith(value, `${type}${tag}<`, v => {
128
+ const parts = v.split(',').map(s => s.trim()).filter(s => s);
124
129
 
125
- if (isSized) {
126
- parts.pop();
130
+ if (isSized) {
131
+ parts.pop();
132
+ }
133
+
134
+ return `${tag}<${parts.join(',')}>`;
135
+ });
127
136
  }
128
137
 
129
- return `${tag}<${parts.join(',')}>`;
130
- }), value);
138
+ return value;
139
+ };
131
140
  }
132
141
 
133
142
  function removeColons() {
@@ -181,13 +190,17 @@ function removeGenerics() {
181
190
 
182
191
  return value;
183
192
  };
193
+ }
194
+ /** @internal */
195
+
196
+
197
+ function pairOfReplacer(v) {
198
+ return `(${v},${v})`;
184
199
  } // remove the PairOf wrappers
185
200
 
186
201
 
187
202
  function removePairOf() {
188
- const replacer = inner => `(${inner},${inner})`;
189
-
190
- return value => replaceTagWith(value, 'PairOf<', replacer);
203
+ return value => replaceTagWith(value, 'PairOf<', pairOfReplacer);
191
204
  } // remove the type traits
192
205
 
193
206
 
@@ -213,13 +226,17 @@ function removeTraits() {
213
226
  .replace(from5, 'Lookup') // replace `<...>::Type`
214
227
  .replace(from6, '');
215
228
  };
229
+ }
230
+ /** @internal */
231
+
232
+
233
+ function wrapReplacer(v) {
234
+ return v;
216
235
  } // remove wrapping values, i.e. Box<Proposal> -> Proposal
217
236
 
218
237
 
219
238
  function removeWrap(check) {
220
- const replacer = inner => inner;
221
-
222
- return value => replaceTagWith(value, check, replacer);
239
+ return value => replaceTagWith(value, check, wrapReplacer);
223
240
  }
224
241
 
225
242
  const sanitizeMap = new Map(); // eslint-disable-next-line @typescript-eslint/ban-types
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./cjs/detectPackage.js"
21
21
  ],
22
22
  "type": "module",
23
- "version": "8.8.2-1",
23
+ "version": "8.8.3-0",
24
24
  "main": "./cjs/index.js",
25
25
  "module": "./index.js",
26
26
  "types": "./index.d.ts",
package/packageInfo.js CHANGED
@@ -5,5 +5,5 @@ export const packageInfo = {
5
5
  name: '@polkadot/types-codec',
6
6
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
7
7
  type: 'esm',
8
- version: '8.8.2-1'
8
+ version: '8.8.3-0'
9
9
  };
package/utils/sanitize.js CHANGED
@@ -55,12 +55,14 @@ export function alias(src, dest, withChecks = true) {
55
55
  }
56
56
  export function cleanupCompact() {
57
57
  return value => {
58
- for (let index = 0; index < value.length; index++) {
59
- if (value[index] === '<') {
60
- const end = findClosing(value, index + 1) - 14;
61
-
62
- if (value.substring(end, end + 14) === ' as HasCompact') {
63
- value = `Compact<${value.substring(index + 1, end)}>`;
58
+ if (value.includes(' as HasCompact')) {
59
+ for (let index = 0; index < value.length; index++) {
60
+ if (value[index] === '<') {
61
+ const end = findClosing(value, index + 1) - 14;
62
+
63
+ if (value.substring(end, end + 14) === ' as HasCompact') {
64
+ value = `Compact<${value.substring(index + 1, end)}>`;
65
+ }
64
66
  }
65
67
  }
66
68
  }
@@ -97,15 +99,22 @@ function replaceTagWith(value, matcher, replacer) {
97
99
 
98
100
 
99
101
  export function removeExtensions(type, isSized) {
100
- return value => BOUNDED.reduce((value, tag) => replaceTagWith(value, `${type}${tag}<`, inner => {
101
- const parts = inner.split(',').map(s => s.trim()).filter(s => s);
102
+ return value => {
103
+ for (let i = 0; i < BOUNDED.length; i++) {
104
+ const tag = BOUNDED[i];
105
+ value = replaceTagWith(value, `${type}${tag}<`, v => {
106
+ const parts = v.split(',').map(s => s.trim()).filter(s => s);
102
107
 
103
- if (isSized) {
104
- parts.pop();
108
+ if (isSized) {
109
+ parts.pop();
110
+ }
111
+
112
+ return `${tag}<${parts.join(',')}>`;
113
+ });
105
114
  }
106
115
 
107
- return `${tag}<${parts.join(',')}>`;
108
- }), value);
116
+ return value;
117
+ };
109
118
  }
110
119
  export function removeColons() {
111
120
  return (value, {
@@ -156,12 +165,16 @@ export function removeGenerics() {
156
165
 
157
166
  return value;
158
167
  };
168
+ }
169
+ /** @internal */
170
+
171
+ function pairOfReplacer(v) {
172
+ return `(${v},${v})`;
159
173
  } // remove the PairOf wrappers
160
174
 
161
- export function removePairOf() {
162
- const replacer = inner => `(${inner},${inner})`;
163
175
 
164
- return value => replaceTagWith(value, 'PairOf<', replacer);
176
+ export function removePairOf() {
177
+ return value => replaceTagWith(value, 'PairOf<', pairOfReplacer);
165
178
  } // remove the type traits
166
179
 
167
180
  export function removeTraits() {
@@ -186,12 +199,16 @@ export function removeTraits() {
186
199
  .replace(from5, 'Lookup') // replace `<...>::Type`
187
200
  .replace(from6, '');
188
201
  };
202
+ }
203
+ /** @internal */
204
+
205
+ function wrapReplacer(v) {
206
+ return v;
189
207
  } // remove wrapping values, i.e. Box<Proposal> -> Proposal
190
208
 
191
- export function removeWrap(check) {
192
- const replacer = inner => inner;
193
209
 
194
- return value => replaceTagWith(value, check, replacer);
210
+ export function removeWrap(check) {
211
+ return value => replaceTagWith(value, check, wrapReplacer);
195
212
  }
196
213
  const sanitizeMap = new Map(); // eslint-disable-next-line @typescript-eslint/ban-types
197
214