name: Compact
description: A compact length-encoding codec wrapper. It performs the same function as Length, however differs in that it uses a variable number of bytes to do the actual encoding. This is mostly used by other types to add length-prefixed encoding, or in the case of wrapped types, taking a number and making the compact representation thereof
Hierarchy
↳ Compact
Implements
Constructors
constructor
⊕ new Compact(Type: Constructor< UInt | Moment>, value?: AnyNumber): Compact
Overrides Base.constructor
Defined in codec/Compact.ts:22
Parameters:
| Name | Type | Default value |
|---|---|---|
| Type | Constructor< UInt | Moment> | - |
Default value value |
AnyNumber | 0 |
Returns: Compact
Properties
<Static> addLengthPrefix
● addLengthPrefix: compactAddLength = compactAddLength
Defined in codec/Compact.ts:40
Prepend a Uint8Array with its compact length. param: The Uint8Array to be prefixed
<Static> decodeU8a
● decodeU8a: compactFromU8a = compactFromU8a
Defined in codec/Compact.ts:41
<Static> encodeU8a
● encodeU8a: compactToU8a = compactToU8a
Defined in codec/Compact.ts:42
Accessors
encodedLength
getencodedLength(): number
Defined in codec/Compact.ts:71
description: The length of the value when encoded as a Uint8Array
Returns: number
Methods
bitLength
▸ bitLength(): UIntBitLength
Defined in codec/Compact.ts:78
description: Returns the number of bits in the value
Returns: UIntBitLength
toBn
▸ toBn(): BN
Defined in codec/Compact.ts:85
description: Returns the BN representation of the number
Returns: BN
toHex
▸ toHex(): any
Defined in codec/Compact.ts:92
description: Returns a hex string representation of the value
Returns: any
toJSON
▸ toJSON(): any
Implementation of Codec.toJSON
Defined in codec/Compact.ts:99
description: Converts the Object to JSON, typically used for RPC transfers
Returns: any
toNumber
▸ toNumber(): number
Defined in codec/Compact.ts:106
description: Returns the number representation for the value
Returns: number
toString
▸ toString(): string
Implementation of Codec.toString
Defined in codec/Compact.ts:113
description: Returns the string representation of the value
Returns: string
toU8a
▸ toU8a(isBare?: undefined | false | true): Uint8Array
Defined in codec/Compact.ts:121
description: Encodes the value as a Uint8Array as per the parity-codec specifications
Parameters:
| Name | Type | Description |
|---|---|---|
Optional isBare |
undefined | false | true |
true when the value has none of the type-specific prefixes (internal) |
Returns: Uint8Array
<Static> decodeCompact
▸ decodeCompact(Type: Constructor< UInt | Moment>, value: AnyNumber): Moment | UInt
Defined in codec/Compact.ts:50
Parameters:
| Name | Type |
|---|---|
| Type | Constructor< UInt | Moment> |
| value | AnyNumber |
<Static> stripLengthPrefix
▸ stripLengthPrefix(u8a: Uint8Array, bitLength?: UIntBitLength): Uint8Array
Defined in codec/Compact.ts:44
Parameters:
| Name | Type | Default value |
|---|---|---|
| u8a | Uint8Array |
- |
Default value bitLength |
UIntBitLength | DEFAULT_BITLENGTH |
Returns: Uint8Array
<Static> with
▸ with(Type: Constructor< UInt | Moment>): Constructor<Compact>
Defined in codec/Compact.ts:27
Parameters:
| Name | Type |
|---|---|
| Type | Constructor< UInt | Moment> |
Returns: Constructor<Compact>