Polkadot JS APIGlobals"codec/Vec"Vec

# Class: Vec <T>

name Vec

description This manages codec arrays. Internally it keeps track of the length (as decoded) and allows construction with the passed Type in the constructor. It is an extension to Array, providing specific encoding/decoding on top of the base type.

# Type parameters

T: Codec

# Hierarchy

AbstractArray‹T›

Vec

# Implements

# Indexable

  • [ n: number]: T

name Vec

description This manages codec arrays. Internally it keeps track of the length (as decoded) and allows construction with the passed Type in the constructor. It is an extension to Array, providing specific encoding/decoding on top of the base type.

# Index

# Constructors

# Properties

# Accessors

# Methods

# Constructors

# constructor

+ new Vec(registry: Registry, Type: Constructor‹T› | keyof InterfaceTypes, value: VecCodec› | Uint8Array | string | unknown[]): Vec

Overrides void

Defined in packages/types/src/codec/Vec.ts:23

Parameters:

Name Type Default
registry Registry -
Type Constructor‹T› | keyof InterfaceTypes -
value VecCodec› | Uint8Array | string | unknown[] []

Returns: Vec

# Properties

# Readonly registry

registry: Registry

Implementation of Codec.registry

Inherited from AbstractArray.registry

Defined in packages/types/src/codec/AbstractArray.ts:23

# Accessors

# Type

get Type(): string

Defined in packages/types/src/codec/Vec.ts:69

description The type for the items

Returns: string


# encodedLength

get encodedLength(): number

Inherited from AbstractArray.encodedLength

Defined in packages/types/src/codec/AbstractArray.ts:34

description The length of the value when encoded as a Uint8Array

Returns: number


# hash

get hash(): H256

Inherited from AbstractArray.hash

Defined in packages/types/src/codec/AbstractArray.ts:43

description returns a hash of the contents

Returns: H256


# isEmpty

get isEmpty(): boolean

Inherited from AbstractArray.isEmpty

Defined in packages/types/src/codec/AbstractArray.ts:50

description Checks if the value is an empty value

Returns: boolean


# length

get length(): number

Inherited from AbstractArray.length

Overrides void

Defined in packages/types/src/codec/AbstractArray.ts:57

description The length of the value

Returns: number

# Methods

# eq

eq(other?: unknown): boolean

Implementation of Codec

Inherited from AbstractArray.eq

Defined in packages/types/src/codec/AbstractArray.ts:65

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

Parameters:

Name Type
other? unknown

Returns: boolean


# filter

filter(callbackfn: function, thisArg?: unknown): T[]

Inherited from AbstractArray.filter

Overrides void

Defined in packages/types/src/codec/AbstractArray.ts:144

description Filters the array with the callback

Parameters:

callbackfn: function

The filter function

▸ (value: T, index: number, array: T[]): boolean

Parameters:

Name Type
value T
index number
array T[]

Optional thisArg: unknown

The this object to apply the result to

Returns: T[]


# includes

includes(check: unknown): boolean

Inherited from AbstractArray.includes

Defined in packages/types/src/codec/AbstractArray.ts:160

description Checks if the array includes a specific value

Parameters:

Name Type
check unknown

Returns: boolean


# indexOf

indexOf(_other?: unknown): number

Overrides void

Defined in packages/types/src/codec/Vec.ts:76

description Finds the index of the value in the array

Parameters:

Name Type
_other? unknown

Returns: number


# map

map<U>(callbackfn: function, thisArg?: unknown): U[]

Inherited from AbstractArray.map

Overrides void

Defined in packages/types/src/codec/AbstractArray.ts:153

description Maps the array with the callback

Type parameters:

U

Parameters:

callbackfn: function

The mapping function

▸ (value: T, index: number, array: T[]): U

Parameters:

Name Type
value T
index number
array T[]

Optional thisArg: unknown

The this onject to apply the result to

Returns: U[]


# toArray

toArray(): T[]

Inherited from AbstractArray.toArray

Defined in packages/types/src/codec/AbstractArray.ts:72

description Converts the Object to an standard JavaScript Array

Returns: T[]


# toHex

toHex(): string

Inherited from AbstractArray.toHex

Defined in packages/types/src/codec/AbstractArray.ts:79

description Returns a hex string representation of the value

Returns: string


# toHuman

toHuman(isExtended?: undefined | false | true): AnyJson

Implementation of Codec

Inherited from AbstractArray.toHuman

Defined in packages/types/src/codec/AbstractArray.ts:86

description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information

Parameters:

Name Type
isExtended? undefined | false | true

Returns: AnyJson


# toJSON

toJSON(): AnyJson

Implementation of Codec

Inherited from AbstractArray.toJSON

Defined in packages/types/src/codec/AbstractArray.ts:95

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

Returns: AnyJson


# toRawType

toRawType(): string

Implementation of Codec

Overrides AbstractArray.toRawType

Defined in packages/types/src/codec/Vec.ts:94

description Returns the base runtime type name for this instance

Returns: string


# toString

toString(): string

Implementation of Codec

Inherited from AbstractArray.toString

Overrides void

Defined in packages/types/src/codec/AbstractArray.ts:109

description Returns the string representation of the value

Returns: string


# toU8a

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

Inherited from AbstractArray.toU8a

Defined in packages/types/src/codec/AbstractArray.ts:122

description Encodes the value as a Uint8Array as per the SCALE specifications

Parameters:

Name Type Description
isBare? undefined | false | true true when the value has none of the type-specific prefixes (internal)

Returns: Uint8Array


# Static with

with<O>(Type: Constructor‹O› | keyof InterfaceTypes): ConstructorVec‹O››

Defined in packages/types/src/codec/Vec.ts:58

Type parameters:

O: Codec

Parameters:

Name Type
Type Constructor‹O› | keyof InterfaceTypes

Returns: ConstructorVec‹O››