name: Option

description: An Option is an optional field. Basically the first byte indicates that there is is value to follow. If the byte is 1 there is an actual value. So the Option implements that - decodes, checks for optionality and wraps the required structure with a value if/as required/found.

Type parameters

T : Codec

Hierarchy

Base<T>

↳ Option

Implements

Constructors

constructor

⊕ new Option(Type: Constructor, value?: any): Option

Overrides Base.constructor

Defined in codec/Option.ts:19

Parameters:

Name Type
Type Constructor
Optional value any

Returns: Option


Accessors

encodedLength

getencodedLength(): number

Defined in codec/Option.ts:52

description: The length of the value when encoded as a Uint8Array

Returns: number


isNone

getisNone(): boolean

Defined in codec/Option.ts:60

description: Checks if the Option has no value

Returns: boolean


isSome

getisSome(): boolean

Defined in codec/Option.ts:67

description: Checks if the Option has a value

Returns: boolean


value

getvalue(): Codec

Defined in codec/Option.ts:74

description: The actual value for the Option

Returns: Codec


Methods

toHex

▸ toHex(): string

Implementation of Codec.toHex

Defined in codec/Option.ts:81

description: Returns a hex string representation of the value

Returns: string


toJSON

▸ toJSON(): any

Implementation of Codec.toJSON

Defined in codec/Option.ts:88

description: Converts the Object to JSON, typically used for RPC transfers

Returns: any


toString

▸ toString(): string

Implementation of Codec.toString

Defined in codec/Option.ts:95

description: Returns the string representation of the value

Returns: string


toU8a

▸ toU8a(isBare?: undefined | false | true): Uint8Array

Implementation of Codec.toU8a

Defined in codec/Option.ts:103

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

▸ unwrap(): T

Defined in codec/Option.ts:121

description: Returns the value that the Option represents (if available)

Returns: T


<Static> decodeOption

▸ decodeOption<O>(Type: Constructor, value?: any): Codec

Defined in codec/Option.ts:26

Type parameters:

O

Parameters:

Name Type
Type Constructor
Optional value any

Returns: Codec


<Static> with

▸ with<O>(Type: Constructor): Constructor<Option<O>>

Defined in codec/Option.ts:41

Type parameters:

O : Codec

Parameters:

Name Type
Type Constructor

Returns: Constructor<Option<O>>


results matching ""

    No results matching ""