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:51

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

Returns: number


isNone

getisNone(): boolean

Defined in codec/Option.ts:59

description: Checks if the Option has no value

Returns: boolean


isSome

getisSome(): boolean

Defined in codec/Option.ts:66

description: Checks if the Option has a value

Returns: boolean


value

getvalue(): Codec

Defined in codec/Option.ts:73

description: The actual value for the Option

Returns: Codec


Methods

eq

▸ eq(other?: any): boolean

Implementation of Codec.eq

Defined in codec/Option.ts:80

description: Compares the value of the input to see if there is a match

Parameters:

Name Type
Optional other any

Returns: boolean


toHex

▸ toHex(): string

Implementation of Codec.toHex

Defined in codec/Option.ts:91

description: Returns a hex string representation of the value

Returns: string


toJSON

▸ toJSON(): any

Implementation of Codec.toJSON

Defined in codec/Option.ts:98

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:105

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:113

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:131

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

Returns: T


unwrapOr

▸ unwrapOr<O>(defaultValue: O): T | O

Defined in codec/Option.ts:143

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

Type parameters:

O

Parameters:

Name Type Description
defaultValue O The value to return if the option isNone

Returns: T | O


<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:40

Type parameters:

O : Codec

Parameters:

Name Type
Type Constructor

Returns: Constructor<Option<O>>


results matching ""

    No results matching ""