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?: Compact | AnyNumber): Compact
Overrides Base.constructor
Defined in codec/Compact.ts:23
Parameters:
| Name | Type | Default value | |
|---|---|---|---|
| Type | Constructor<UInt \ | Moment> | - |
Default value value |
Compact \ | AnyNumber | 0 |
Returns: Compact
Properties
<Static> addLengthPrefix
● addLengthPrefix: compactAddLength = compactAddLength
Defined in codec/Compact.ts:41
Prepend a Uint8Array with its compact length.
param: The Uint8Array to be prefixed
<Static> decodeU8a
● decodeU8a: compactFromU8a = compactFromU8a
Defined in codec/Compact.ts:42
<Static> encodeU8a
● encodeU8a: compactToU8a = compactToU8a
Defined in codec/Compact.ts:43
Accessors
encodedLength
getencodedLength(): number
Defined in codec/Compact.ts:72
description: The length of the value when encoded as a Uint8Array
Returns: number
isEmpty
getisEmpty(): boolean
Defined in codec/Compact.ts:79
description: Checks if the value is an empty value
Returns: boolean
Methods
bitLength
▸ bitLength(): UIntBitLength
Defined in codec/Compact.ts:86
description: Returns the number of bits in the value
Returns: UIntBitLength
eq
▸ eq(other?: any): boolean
Defined in codec/Compact.ts:93
description: Compares the value of the input to see if there is a match
Parameters:
| Name | Type |
|---|---|
Optional other |
any |
Returns: boolean
toBn
▸ toBn(): BN
Defined in codec/Compact.ts:104
description: Returns the BN representation of the number
Returns: BN
toHex
▸ toHex(): any
Defined in codec/Compact.ts:111
description: Returns a hex string representation of the value
Returns: any
toJSON
▸ toJSON(): any
Implementation of Codec.toJSON
Defined in codec/Compact.ts:118
description: Converts the Object to JSON, typically used for RPC transfers
Returns: any
toNumber
▸ toNumber(): number
Defined in codec/Compact.ts:125
description: Returns the number representation for the value
Returns: number
toString
▸ toString(): string
Implementation of Codec.toString
Defined in codec/Compact.ts:132
description: Returns the string representation of the value
Returns: string
toU8a
▸ toU8a(isBare?: undefined | false | true): Uint8Array
Defined in codec/Compact.ts:140
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
unwrap
Defined in codec/Compact.ts:147
description: Returns the embedded UInt or Moment value
<Static> decodeCompact
▸ decodeCompact(Type: Constructor<UInt | Moment>, value: Compact | AnyNumber): Moment | UInt
Defined in codec/Compact.ts:51
Parameters:
| Name | Type | |
|---|---|---|
| Type | Constructor<UInt \ | Moment> |
| value | Compact \ | AnyNumber |
<Static> stripLengthPrefix
▸ stripLengthPrefix(u8a: Uint8Array, bitLength?: UIntBitLength): Uint8Array
Defined in codec/Compact.ts:45
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:28
Parameters:
| Name | Type | |
|---|---|---|
| Type | Constructor<UInt \ | Moment> |
Returns: Constructor<Compact>