@polkadot/types-codec 8.8.3-4 → 8.8.3-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.
File without changes
File without changes
@@ -4,7 +4,7 @@ import type { AnyJson, BareOpts, Codec, Inspect, IU8a, Registry } from '../types
4
4
  * @name Base
5
5
  * @description A type extends the Base class, when it holds a value
6
6
  */
7
- export declare abstract class Base<T extends Codec> implements Codec {
7
+ export declare abstract class AbstractBase<T extends Codec> implements Codec {
8
8
  #private;
9
9
  createdAtHash?: IU8a;
10
10
  readonly initialU8aLength?: number;
@@ -5,7 +5,7 @@
5
5
  * @name Base
6
6
  * @description A type extends the Base class, when it holds a value
7
7
  */
8
- export class Base {
8
+ export class AbstractBase {
9
9
  #raw;
10
10
 
11
11
  constructor(registry, value, initialU8aLength) {
File without changes
File without changes
@@ -1,2 +1,3 @@
1
- export { AbstractArray } from './AbstractArray';
2
- export { AbstractInt } from './AbstractInt';
1
+ export { AbstractArray } from './Array';
2
+ export { AbstractBase } from './Base';
3
+ export { AbstractInt } from './Int';
package/abstract/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- export { AbstractArray } from "./AbstractArray.js";
4
- export { AbstractInt } from "./AbstractInt.js";
3
+ export { AbstractArray } from "./Array.js";
4
+ export { AbstractBase } from "./Base.js";
5
+ export { AbstractInt } from "./Int.js";
package/base/Int.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AnyNumber, CodecClass, Registry, UIntBitLength } from '../types';
2
- import { AbstractInt } from '../abstract/AbstractInt';
2
+ import { AbstractInt } from '../abstract/Int';
3
3
  /**
4
4
  * @name Int
5
5
  * @description
package/base/Int.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { AbstractInt } from "../abstract/AbstractInt.js";
3
+ import { AbstractInt } from "../abstract/Int.js";
4
4
  /**
5
5
  * @name Int
6
6
  * @description
package/base/Tuple.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AnyTupleValue, Codec, CodecClass, Inspect, ITuple, Registry } from '../types';
2
- import { AbstractArray } from '../abstract/AbstractArray';
2
+ import { AbstractArray } from '../abstract/Array';
3
3
  declare type TupleType = (CodecClass | string);
4
4
  declare type TupleTypes = TupleType[] | {
5
5
  [index: string]: CodecClass | string;
package/base/Tuple.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { isFunction, isHex, isString, isU8a, stringify, u8aConcatStrict, u8aToU8a } from '@polkadot/util';
4
- import { AbstractArray } from "../abstract/AbstractArray.js";
4
+ import { AbstractArray } from "../abstract/Array.js";
5
5
  import { decodeU8a, mapToTypeMap, typeToConstructor } from "../utils/index.js";
6
6
 
7
7
  function noopSetDefinition(d) {
package/base/UInt.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CodecClass, UIntBitLength } from '../types';
2
- import { AbstractInt } from '../abstract/AbstractInt';
2
+ import { AbstractInt } from '../abstract/Int';
3
3
  /**
4
4
  * @name UInt
5
5
  * @description
package/base/UInt.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { AbstractInt } from "../abstract/AbstractInt.js";
3
+ import { AbstractInt } from "../abstract/Int.js";
4
4
  /**
5
5
  * @name UInt
6
6
  * @description
package/base/Vec.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
2
  import type { Codec, CodecClass, Registry } from '../types';
3
- import { AbstractArray } from '../abstract/AbstractArray';
3
+ import { AbstractArray } from '../abstract/Array';
4
4
  interface Options<T> {
5
5
  definition?: CodecClass<T>;
6
6
  setDefinition?: (d: CodecClass<T>) => CodecClass<T>;
package/base/Vec.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { assert, compactFromU8aLim, isU8a, logger, u8aToU8a } from '@polkadot/util';
4
- import { AbstractArray } from "../abstract/AbstractArray.js";
4
+ import { AbstractArray } from "../abstract/Array.js";
5
5
  import { decodeU8aVec, typeToConstructor } from "../utils/index.js";
6
6
  const MAX_LENGTH = 64 * 1024;
7
7
  const l = logger('Vec');
package/base/VecAny.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Codec } from '../types';
2
- import { AbstractArray } from '../abstract/AbstractArray';
2
+ import { AbstractArray } from '../abstract/Array';
3
3
  /**
4
4
  * @name VecAny
5
5
  * @description
package/base/VecAny.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { AbstractArray } from "../abstract/AbstractArray.js";
3
+ import { AbstractArray } from "../abstract/Array.js";
4
4
  /**
5
5
  * @name VecAny
6
6
  * @description
@@ -1,6 +1,6 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
2
  import type { Codec, CodecClass, Inspect, Registry } from '../types';
3
- import { AbstractArray } from '../abstract/AbstractArray';
3
+ import { AbstractArray } from '../abstract/Array';
4
4
  interface Options<T> {
5
5
  definition?: CodecClass<T>;
6
6
  setDefinition?: (d: CodecClass<T>) => CodecClass<T>;
package/base/VecFixed.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { isU8a, u8aConcatStrict } from '@polkadot/util';
4
- import { AbstractArray } from "../abstract/AbstractArray.js";
4
+ import { AbstractArray } from "../abstract/Array.js";
5
5
  import { decodeU8aVec, typeToConstructor } from "../utils/index.js";
6
6
  import { decodeVec } from "./Vec.js";
7
7
 
package/base/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { Base } from './Base';
2
1
  export { Compact } from './Compact';
3
2
  export { DoNotConstruct } from './DoNotConstruct';
4
3
  export { Enum } from './Enum';
package/base/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- export { Base } from "./Base.js";
4
3
  export { Compact } from "./Compact.js";
5
4
  export { DoNotConstruct } from "./DoNotConstruct.js";
6
5
  export { Enum } from "./Enum.js";
File without changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Base = void 0;
6
+ exports.AbstractBase = void 0;
7
7
 
8
8
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
9
9
  // SPDX-License-Identifier: Apache-2.0
@@ -12,7 +12,7 @@ exports.Base = void 0;
12
12
  * @name Base
13
13
  * @description A type extends the Base class, when it holds a value
14
14
  */
15
- class Base {
15
+ class AbstractBase {
16
16
  #raw;
17
17
 
18
18
  constructor(registry, value, initialU8aLength) {
@@ -120,4 +120,4 @@ class Base {
120
120
 
121
121
  }
122
122
 
123
- exports.Base = Base;
123
+ exports.AbstractBase = AbstractBase;
File without changes
@@ -6,16 +6,24 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "AbstractArray", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _AbstractArray.AbstractArray;
9
+ return _Array.AbstractArray;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "AbstractBase", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Base.AbstractBase;
10
16
  }
11
17
  });
12
18
  Object.defineProperty(exports, "AbstractInt", {
13
19
  enumerable: true,
14
20
  get: function () {
15
- return _AbstractInt.AbstractInt;
21
+ return _Int.AbstractInt;
16
22
  }
17
23
  });
18
24
 
19
- var _AbstractArray = require("./AbstractArray");
25
+ var _Array = require("./Array");
26
+
27
+ var _Base = require("./Base");
20
28
 
21
- var _AbstractInt = require("./AbstractInt");
29
+ var _Int = require("./Int");
package/cjs/base/Int.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Int = void 0;
7
7
 
8
- var _AbstractInt = require("../abstract/AbstractInt");
8
+ var _Int = require("../abstract/Int");
9
9
 
10
10
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
11
11
  // SPDX-License-Identifier: Apache-2.0
@@ -20,7 +20,7 @@ var _AbstractInt = require("../abstract/AbstractInt");
20
20
  * is available here.
21
21
  * @noInheritDoc
22
22
  */
23
- class Int extends _AbstractInt.AbstractInt {
23
+ class Int extends _Int.AbstractInt {
24
24
  constructor(registry) {
25
25
  let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
26
26
  let bitLength = arguments.length > 2 ? arguments[2] : undefined;
package/cjs/base/Tuple.js CHANGED
@@ -7,7 +7,7 @@ exports.Tuple = void 0;
7
7
 
8
8
  var _util = require("@polkadot/util");
9
9
 
10
- var _AbstractArray = require("../abstract/AbstractArray");
10
+ var _Array = require("../abstract/Array");
11
11
 
12
12
  var _utils = require("../utils");
13
13
 
@@ -45,7 +45,7 @@ function decodeTuple(registry, result, value, Classes) {
45
45
  */
46
46
 
47
47
 
48
- class Tuple extends _AbstractArray.AbstractArray {
48
+ class Tuple extends _Array.AbstractArray {
49
49
  #Types;
50
50
 
51
51
  constructor(registry, Types, value) {
package/cjs/base/UInt.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UInt = void 0;
7
7
 
8
- var _AbstractInt = require("../abstract/AbstractInt");
8
+ var _Int = require("../abstract/Int");
9
9
 
10
10
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
11
11
  // SPDX-License-Identifier: Apache-2.0
@@ -20,7 +20,7 @@ var _AbstractInt = require("../abstract/AbstractInt");
20
20
  * is available here.
21
21
  * @noInheritDoc
22
22
  */
23
- class UInt extends _AbstractInt.AbstractInt {
23
+ class UInt extends _Int.AbstractInt {
24
24
  static with(bitLength, typeName) {
25
25
  return class extends UInt {
26
26
  constructor(registry, value) {
package/cjs/base/Vec.js CHANGED
@@ -8,7 +8,7 @@ exports.decodeVec = decodeVec;
8
8
 
9
9
  var _util = require("@polkadot/util");
10
10
 
11
- var _AbstractArray = require("../abstract/AbstractArray");
11
+ var _Array = require("../abstract/Array");
12
12
 
13
13
  var _utils = require("../utils");
14
14
 
@@ -61,7 +61,7 @@ function decodeVec(registry, result, value, startAt, Type) {
61
61
  */
62
62
 
63
63
 
64
- class Vec extends _AbstractArray.AbstractArray {
64
+ class Vec extends _Array.AbstractArray {
65
65
  #Type;
66
66
 
67
67
  constructor(registry, Type) {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.VecAny = void 0;
7
7
 
8
- var _AbstractArray = require("../abstract/AbstractArray");
8
+ var _Array = require("../abstract/Array");
9
9
 
10
10
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
11
11
  // SPDX-License-Identifier: Apache-2.0
@@ -17,7 +17,7 @@ var _AbstractArray = require("../abstract/AbstractArray");
17
17
  * a vector, this can be used to manage array-like structures with variable arguments of
18
18
  * any types
19
19
  */
20
- class VecAny extends _AbstractArray.AbstractArray {
20
+ class VecAny extends _Array.AbstractArray {
21
21
  /**
22
22
  * @description Returns the base runtime type name for this instance
23
23
  */
@@ -7,7 +7,7 @@ exports.VecFixed = void 0;
7
7
 
8
8
  var _util = require("@polkadot/util");
9
9
 
10
- var _AbstractArray = require("../abstract/AbstractArray");
10
+ var _Array = require("../abstract/Array");
11
11
 
12
12
  var _utils = require("../utils");
13
13
 
@@ -25,7 +25,7 @@ function noopSetDefinition(d) {
25
25
  */
26
26
 
27
27
 
28
- class VecFixed extends _AbstractArray.AbstractArray {
28
+ class VecFixed extends _Array.AbstractArray {
29
29
  #Type;
30
30
 
31
31
  constructor(registry, Type, length) {
package/cjs/base/index.js CHANGED
@@ -3,12 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Base", {
7
- enumerable: true,
8
- get: function () {
9
- return _Base.Base;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "Compact", {
13
7
  enumerable: true,
14
8
  get: function () {
@@ -82,8 +76,6 @@ Object.defineProperty(exports, "VecFixed", {
82
76
  }
83
77
  });
84
78
 
85
- var _Base = require("./Base");
86
-
87
79
  var _Compact = require("./Compact");
88
80
 
89
81
  var _DoNotConstruct = require("./DoNotConstruct");
@@ -7,7 +7,7 @@ exports.CodecMap = void 0;
7
7
 
8
8
  var _util = require("@polkadot/util");
9
9
 
10
- var _AbstractArray = require("../abstract/AbstractArray");
10
+ var _Array = require("../abstract/Array");
11
11
 
12
12
  var _Enum = require("../base/Enum");
13
13
 
@@ -44,7 +44,7 @@ function decodeMapFromMap(registry, KeyClass, ValClass, value) {
44
44
  const output = new Map();
45
45
 
46
46
  for (const [key, val] of value.entries()) {
47
- const isComplex = KeyClass.prototype instanceof _AbstractArray.AbstractArray || KeyClass.prototype instanceof _Struct.Struct || KeyClass.prototype instanceof _Enum.Enum;
47
+ const isComplex = KeyClass.prototype instanceof _Array.AbstractArray || KeyClass.prototype instanceof _Struct.Struct || KeyClass.prototype instanceof _Enum.Enum;
48
48
 
49
49
  try {
50
50
  output.set(key instanceof KeyClass ? key : new KeyClass(registry, isComplex ? JSON.parse(key) : key), val instanceof ValClass ? val : new ValClass(registry, val));
@@ -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.3-4'
14
+ version: '8.8.3-7'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
@@ -140,10 +140,7 @@ function removeExtensions(type, isSized) {
140
140
  }
141
141
 
142
142
  function removeColons() {
143
- return function (value) {
144
- let {
145
- allowNamespaces
146
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
143
+ return value => {
147
144
  let index = 0;
148
145
 
149
146
  while (index !== -1) {
@@ -152,10 +149,6 @@ function removeColons() {
152
149
  if (index === 0) {
153
150
  value = value.substring(2);
154
151
  } else if (index !== -1) {
155
- if (allowNamespaces) {
156
- return value;
157
- }
158
-
159
152
  let start = index;
160
153
 
161
154
  while (start !== -1 && !BOX_PRECEDING.includes(value[start])) {
@@ -177,7 +170,7 @@ function removeGenerics() {
177
170
  // check against the allowed wrappers, be it Vec<..>, Option<...> ...
178
171
  const box = ALLOWED_BOXES.find(box => {
179
172
  const start = index - box.length;
180
- return start >= 0 && value.substring(start, start + box.length) === box && ( // make sure it is stand-alone, i.e. don't catch ElectionResult<...> as Result<...>
173
+ return start >= 0 && value.substring(start, index) === box && ( // make sure it is stand-alone, i.e. don't catch ElectionResult<...> as Result<...>
181
174
  start === 0 || BOX_PRECEDING.includes(value[start - 1]));
182
175
  }); // we have not found anything, unwrap generic innards
183
176
 
@@ -190,17 +183,13 @@ function removeGenerics() {
190
183
 
191
184
  return value;
192
185
  };
193
- }
194
- /** @internal */
195
-
196
-
197
- function pairOfReplacer(v) {
198
- return `(${v},${v})`;
199
186
  } // remove the PairOf wrappers
200
187
 
201
188
 
202
189
  function removePairOf() {
203
- return value => replaceTagWith(value, 'PairOf<', pairOfReplacer);
190
+ const replacer = v => `(${v},${v})`;
191
+
192
+ return value => replaceTagWith(value, 'PairOf<', replacer);
204
193
  } // remove the type traits
205
194
 
206
195
 
@@ -226,40 +215,31 @@ function removeTraits() {
226
215
  .replace(from5, 'Lookup') // replace `<...>::Type`
227
216
  .replace(from6, '');
228
217
  };
229
- }
230
- /** @internal */
231
-
232
-
233
- function wrapReplacer(v) {
234
- return v;
235
218
  } // remove wrapping values, i.e. Box<Proposal> -> Proposal
236
219
 
237
220
 
238
221
  function removeWrap(check) {
239
- return value => replaceTagWith(value, check, wrapReplacer);
222
+ const replacer = v => v;
223
+
224
+ return value => replaceTagWith(value, check, replacer);
240
225
  }
241
226
 
242
- const sanitizeMap = new Map(); // eslint-disable-next-line @typescript-eslint/ban-types
227
+ const sanitizeMap = new Map();
243
228
 
244
- function sanitize(value, options) {
229
+ function sanitize(value) {
245
230
  const startValue = value.toString();
246
- let result = startValue;
231
+ const memoized = sanitizeMap.get(startValue);
247
232
 
248
- if (!options) {
249
- const memoized = sanitizeMap.get(startValue);
250
-
251
- if (memoized) {
252
- return memoized;
253
- }
233
+ if (memoized) {
234
+ return memoized;
254
235
  }
255
236
 
256
- for (let i = 0; i < mappings.length; i++) {
257
- result = mappings[i](result, options);
258
- }
237
+ let result = startValue;
259
238
 
260
- if (!options) {
261
- sanitizeMap.set(startValue, result);
239
+ for (let i = 0; i < mappings.length; i++) {
240
+ result = mappings[i](result);
262
241
  }
263
242
 
243
+ sanitizeMap.set(startValue, result);
264
244
  return result;
265
245
  }
package/extended/Map.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { compactFromU8aLim, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcatStrict, u8aToHex, u8aToU8a } from '@polkadot/util';
4
- import { AbstractArray } from "../abstract/AbstractArray.js";
4
+ import { AbstractArray } from "../abstract/Array.js";
5
5
  import { Enum } from "../base/Enum.js";
6
6
  import { Struct } from "../native/Struct.js";
7
7
  import { compareMap, decodeU8a, sortMap, typeToConstructor } from "../utils/index.js";
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./cjs/detectPackage.js"
21
21
  ],
22
22
  "type": "module",
23
- "version": "8.8.3-4",
23
+ "version": "8.8.3-7",
24
24
  "main": "./cjs/index.js",
25
25
  "module": "./index.js",
26
26
  "types": "./index.d.ts",
@@ -37,26 +37,26 @@
37
37
  "require": "./cjs/abstract/index.js",
38
38
  "default": "./abstract/index.js"
39
39
  },
40
- "./abstract/AbstractArray": {
41
- "types": "./abstract/AbstractArray.d.ts",
42
- "require": "./cjs/abstract/AbstractArray.js",
43
- "default": "./abstract/AbstractArray.js"
40
+ "./abstract/Array": {
41
+ "types": "./abstract/Array.d.ts",
42
+ "require": "./cjs/abstract/Array.js",
43
+ "default": "./abstract/Array.js"
44
44
  },
45
- "./abstract/AbstractInt": {
46
- "types": "./abstract/AbstractInt.d.ts",
47
- "require": "./cjs/abstract/AbstractInt.js",
48
- "default": "./abstract/AbstractInt.js"
45
+ "./abstract/Base": {
46
+ "types": "./abstract/Base.d.ts",
47
+ "require": "./cjs/abstract/Base.js",
48
+ "default": "./abstract/Base.js"
49
+ },
50
+ "./abstract/Int": {
51
+ "types": "./abstract/Int.d.ts",
52
+ "require": "./cjs/abstract/Int.js",
53
+ "default": "./abstract/Int.js"
49
54
  },
50
55
  "./base": {
51
56
  "types": "./base/index.d.ts",
52
57
  "require": "./cjs/base/index.js",
53
58
  "default": "./base/index.js"
54
59
  },
55
- "./base/Base": {
56
- "types": "./base/Base.d.ts",
57
- "require": "./cjs/base/Base.js",
58
- "default": "./base/Base.js"
59
- },
60
60
  "./base/Compact": {
61
61
  "types": "./base/Compact.d.ts",
62
62
  "require": "./cjs/base/Compact.js",
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.3-4'
8
+ version: '8.8.3-7'
9
9
  };
@@ -1,7 +1,5 @@
1
- interface SanitizeOptions {
2
- allowNamespaces?: boolean;
3
- }
4
- declare type Mapper = (value: string, options?: SanitizeOptions) => string;
1
+ import { AnyString } from '../types';
2
+ declare type Mapper = (value: string) => string;
5
3
  export declare function trim(): Mapper;
6
4
  export declare function findClosing(value: string, start: number): number;
7
5
  export declare function alias(src: string, dest: string, withChecks?: boolean): Mapper;
@@ -13,5 +11,5 @@ export declare function removeGenerics(): Mapper;
13
11
  export declare function removePairOf(): Mapper;
14
12
  export declare function removeTraits(): Mapper;
15
13
  export declare function removeWrap(check: string): Mapper;
16
- export declare function sanitize(value: String | string, options?: SanitizeOptions): string;
14
+ export declare function sanitize(value: AnyString): string;
17
15
  export {};
package/utils/sanitize.js CHANGED
@@ -117,9 +117,7 @@ export function removeExtensions(type, isSized) {
117
117
  };
118
118
  }
119
119
  export function removeColons() {
120
- return (value, {
121
- allowNamespaces
122
- } = {}) => {
120
+ return value => {
123
121
  let index = 0;
124
122
 
125
123
  while (index !== -1) {
@@ -128,10 +126,6 @@ export function removeColons() {
128
126
  if (index === 0) {
129
127
  value = value.substring(2);
130
128
  } else if (index !== -1) {
131
- if (allowNamespaces) {
132
- return value;
133
- }
134
-
135
129
  let start = index;
136
130
 
137
131
  while (start !== -1 && !BOX_PRECEDING.includes(value[start])) {
@@ -152,7 +146,7 @@ export function removeGenerics() {
152
146
  // check against the allowed wrappers, be it Vec<..>, Option<...> ...
153
147
  const box = ALLOWED_BOXES.find(box => {
154
148
  const start = index - box.length;
155
- return start >= 0 && value.substring(start, start + box.length) === box && ( // make sure it is stand-alone, i.e. don't catch ElectionResult<...> as Result<...>
149
+ return start >= 0 && value.substring(start, index) === box && ( // make sure it is stand-alone, i.e. don't catch ElectionResult<...> as Result<...>
156
150
  start === 0 || BOX_PRECEDING.includes(value[start - 1]));
157
151
  }); // we have not found anything, unwrap generic innards
158
152
 
@@ -165,16 +159,12 @@ export function removeGenerics() {
165
159
 
166
160
  return value;
167
161
  };
168
- }
169
- /** @internal */
170
-
171
- function pairOfReplacer(v) {
172
- return `(${v},${v})`;
173
162
  } // remove the PairOf wrappers
174
163
 
175
-
176
164
  export function removePairOf() {
177
- return value => replaceTagWith(value, 'PairOf<', pairOfReplacer);
165
+ const replacer = v => `(${v},${v})`;
166
+
167
+ return value => replaceTagWith(value, 'PairOf<', replacer);
178
168
  } // remove the type traits
179
169
 
180
170
  export function removeTraits() {
@@ -199,38 +189,28 @@ export function removeTraits() {
199
189
  .replace(from5, 'Lookup') // replace `<...>::Type`
200
190
  .replace(from6, '');
201
191
  };
202
- }
203
- /** @internal */
204
-
205
- function wrapReplacer(v) {
206
- return v;
207
192
  } // remove wrapping values, i.e. Box<Proposal> -> Proposal
208
193
 
209
-
210
194
  export function removeWrap(check) {
211
- return value => replaceTagWith(value, check, wrapReplacer);
212
- }
213
- const sanitizeMap = new Map(); // eslint-disable-next-line @typescript-eslint/ban-types
195
+ const replacer = v => v;
214
196
 
215
- export function sanitize(value, options) {
197
+ return value => replaceTagWith(value, check, replacer);
198
+ }
199
+ const sanitizeMap = new Map();
200
+ export function sanitize(value) {
216
201
  const startValue = value.toString();
217
- let result = startValue;
202
+ const memoized = sanitizeMap.get(startValue);
218
203
 
219
- if (!options) {
220
- const memoized = sanitizeMap.get(startValue);
221
-
222
- if (memoized) {
223
- return memoized;
224
- }
204
+ if (memoized) {
205
+ return memoized;
225
206
  }
226
207
 
227
- for (let i = 0; i < mappings.length; i++) {
228
- result = mappings[i](result, options);
229
- }
208
+ let result = startValue;
230
209
 
231
- if (!options) {
232
- sanitizeMap.set(startValue, result);
210
+ for (let i = 0; i < mappings.length; i++) {
211
+ result = mappings[i](result);
233
212
  }
234
213
 
214
+ sanitizeMap.set(startValue, result);
235
215
  return result;
236
216
  }