Use stringPascalCase from @polkadot/util (#4211)

This commit is contained in:
Jaco
2021-11-18 06:40:28 +02:00
committed by GitHub
parent cfa25f8dda
commit df44693e5d
4 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ import type { HexString } from '@polkadot/util/types';
import type { CodecHash, Hash } from '../interfaces';
import type { AnyJson, Codec, Constructor, IEnum, Registry } from '../types';
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, objectProperties, stringCamelCase, stringify, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util';
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, objectProperties, stringCamelCase, stringify, stringPascalCase, u8aConcat, u8aToHex } from '@polkadot/util';
import { Null } from '../primitive/Null';
import { mapToTypeMap, typesToMap } from './utils';
@@ -204,7 +204,7 @@ export class Enum implements IEnum {
const isKeys = new Array<string>(keys.length);
for (let i = 0; i < keys.length; i++) {
const name = stringUpperFirst(stringCamelCase(keys[i].replace(' ', '_')));
const name = stringPascalCase(keys[i].replace(' ', '_'));
asKeys[i] = `as${name}`;
isKeys[i] = `is${name}`;
+2 -2
View File
@@ -5,7 +5,7 @@ import type { HexString } from '@polkadot/util/types';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { Constructor, ISet, Registry } from '../types';
import { assert, BN, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, objectProperties, stringCamelCase, stringify, stringUpperFirst, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
import { assert, BN, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, objectProperties, stringify, stringPascalCase, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
import { compareArray } from './utils';
@@ -108,7 +108,7 @@ export class CodecSet extends Set<string> implements ISet<string> {
const isKeys = new Array<string>(keys.length);
for (let i = 0; i < keys.length; i++) {
isKeys[i] = `is${stringUpperFirst(stringCamelCase(keys[i]))}`;
isKeys[i] = `is${stringPascalCase(keys[i])}`;
}
return class extends CodecSet {
@@ -7,7 +7,7 @@ import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDefArray, SiTypeDef
import type { Text, Type } from '../../primitive';
import type { Registry, TypeDef } from '../../types';
import { assert, isNumber, isString, objectSpread, stringCamelCase, stringify, stringUpperFirst } from '@polkadot/util';
import { assert, isNumber, isString, objectSpread, stringCamelCase, stringify, stringPascalCase } from '@polkadot/util';
import { Struct } from '../../codec/Struct';
import { withTypeString } from '../../create/encodeTypes';
@@ -224,7 +224,7 @@ function extractName (types: PortableType[], { id, type: { params, path } }: Por
}
const parts = path
.map((p) => stringUpperFirst(stringCamelCase(p)))
.map((p) => stringPascalCase(p))
.filter((p, index) => {
const lower = p.toLowerCase();