@polkadot/util APIs
- hexToU8a
- u8aToHex
- isHex
- stringToU8a
- formatBalance
- u8aConcat
- isU8a
- u8aToString
- BN
- isFunction
- hexToString
- BN_TEN
- stringToHex
- compactAddLength
- BN_MILLION
- BN_ZERO
- formatNumber
- BN_ONE
- isNumber
- u8aToU8a
- isNull
- u8aEq
- extractTime
- bnToBn
- isUndefined
- BN_TWO
- BN_THOUSAND
- isBn
- isWasm
- isTestChain
- isString
- assert
- hexToBn
- bnToHex
- hexAddPrefix
- isObservable
- arrayFlatten
- bufferToU8a
- BN_BILLION
- isObject
- bnMax
- isBuffer
- u8aToBn
- u8aFixLength
- numberToHex
- hexStripPrefix
- isBoolean
- isAscii
- stringCamelCase
- BN_HUNDRED
- loggerFormat
- detectPackage
- compactFromU8a
- stringify
- numberToU8a
- compactStripLength
- BN_MAX_INTEGER
- isJsonObject
- BN_THREE
- BN_FOUR
- BN_FIVE
- isError
- BN_QUINTILL
- u8aToBuffer
- hexHasPrefix
- stringUpperFirst
Other Related APIs
@polkadot/util#compactStripLength TypeScript Examples
The following examples show how to use
@polkadot/util#compactStripLength.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Query.tsx From crust-apps with Apache License 2.0 | 6 votes |
function keyToName (isConst: boolean, _key: Uint8Array | QueryableStorageEntry<'promise'> | ConstValue): string {
if (isConst) {
const key = _key as ConstValue;
return `const ${key.section}.${key.method}`;
}
const key = _key as Uint8Array | QueryableStorageEntry<'promise'>;
if (isU8a(key)) {
const [, u8a] = compactStripLength(key);
// If the string starts with `:`, handle it as a pure string
return u8a[0] === 0x3a
? u8aToString(u8a)
: u8aToHex(u8a);
}
return `${key.creator.section}.${key.creator.method}`;
}