Skip to main content

Format

Pokémon Types's module format functions allows easy to use typing information across different data structures.

We provide helper functions to convert between indexes from PokemonTypesArrayIndex (number), enums from PokemonTypeName (string) and enums from PokemonTypeId (number), which is the value from PokéApi Pokémon Type resource's id value.

Methods​

formatTypeIdToIndex()​

Returns the TYPES_CHART_MATRIX index from given PokéAPI Pokémon Type resource id. See more about the TYPES_CHART_MATRIX at PokemonDB. The index 0 stands for NORMAL type, index 1 stands for FIRE type etc.

Signature​

formatTypeIdToIndex(typeId: PokemonTypeId) => PokemonTypesArrayIndex
ParameterTypeRequiredDescription
typeIdPokemonTypeIdYesThe PokéAPI Pokémon Type resource id.

Returns​

An index from Pokémon types chart matrix.

Examples​

formatTypeIdToIndex(PokemonTypeId.NORMAL); // returns PokemonTypesArrayIndex.NORMAL

formatTypeIndexToId()​

Returns the PokéAPI Pokémon Type resource id from given TYPES_CHART_MATRIX index. See more about the TYPES_CHART_MATRIX at PokemonDB. The index 0 stands for NORMAL type, index 1 stands for FIRE type etc.

Signature​

formatTypeIndexToId(typeIndex: PokemonTypesArrayIndex) => PokemonTypeId
ParameterTypeRequiredDescription
typeIndexPokemonTypesArrayIndexYesThe index from Pokémon types chart matrix.

Returns​

A PokéAPI Pokémon Type resource id.

Examples​

formatTypeIndexToId(PokemonTypesArrayIndex.NORMAL); // returns PokemonTypeId.NORMAL

formatTypeIndexToName()​

Returns the name of the Pokémon type from given TYPES_CHART_MATRIX index. See more about the TYPES_CHART_MATRIX at PokemonDB. The index 0 stands for NORMAL type, index 1 stands for FIRE type etc.

Signature​

formatTypeIndexToName(typeIndex: PokemonTypesArrayIndex) => PokemonTypeName
ParameterTypeRequiredDescription
typeIndexPokemonTypesArrayIndexYesThe index of Pokémon types chart matrix from given Pokémon type.

Returns​

A name of Pokémon type.

Examples​

formatTypeIndexToName(PokemonTypesArrayIndex.NORMAL); // returns PokemonTypeName.NORMAL

formatTypeNameToIndex()​

Returns the TYPES_CHART_MATRIX index from given Pokémon type name. See more about the TYPES_CHART_MATRIX at PokemonDB. The index 0 stands for NORMAL type, index 1 stands for FIRE type etc.

Signature​

formatTypeNameToIndex(typeName: PokemonTypeName) =>  PokemonTypesArrayIndex
ParameterTypeRequiredDescription
typeNamePokemonTypeNameYesThe string containing the Pokémon type name.

Returns​

An index from Pokémon types chart matrix.

Examples​

formatTypeNameToIndex(PokemonTypeName.NORMAL ); // returns PokemonTypesArrayIndex.NORMAL

formatTypeNameToId()​

Returns the PokéAPI Pokémon Type resource id from given Pokémon type name.

Signature​

formatTypeNameToId(typeName: PokemonTypeName) =>  PokemonTypeId
ParameterTypeRequiredDescription
typeNamePokemonTypeNameYesThe string containing the Pokémon type name.

Returns​

A PokéAPI Pokémon Type resource id.

Examples​

formatTypeNameToId(PokemonTypeName.NORMAL ); // returns PokemonTypeId.NORMAL

formatTypeIdToName()​

Returns the name of the Pokémon type from given PokéAPI Pokémon Type resource id.

Signature​

formatTypeIdToName(typeId: PokemonTypeId) =>  PokemonTypeName
ParameterTypeRequiredDescription
typeIdPokemonTypeIdYesThe PokéAPI Pokémon Type resource id.

Returns​

A name of the Pokémon type.

Examples​

formatTypeIdToName(PokemonTypeId.NORMAL ); // returns PokemonTypeName.NORMAL

Type Definitions​

format​

A "syntatic sugar" object with shortened calls for all Pokémon Type module's format functions.

Types
Object

Properties​

NameValue
id2name()formatTypeIdToName()
id2index()formatTypeIdToIndex()
index2id()formatTypeIndexToId()
index2name()formatTypeIndexToName()
name2id()formatTypeNameToId()
name2index()formatTypeNameToIndex()

PokemonTypeId​

An enum for PokéAPI Type resources' ids.

Types
Enum

Properties​

NameValue
PokemonTypeId.NORMAL1
PokemonTypeId.FIGHTING2
PokemonTypeId.FLYING3
PokemonTypeId.POISON4
PokemonTypeId.GROUND5
PokemonTypeId.ROCK6
PokemonTypeId.BUG7
PokemonTypeId.GHOST8
PokemonTypeId.STEEL9
PokemonTypeId.FIRE10
PokemonTypeId.WATER11
PokemonTypeId.GRASS12
PokemonTypeId.ELECTRIC13
PokemonTypeId.PSYCHIC14
PokemonTypeId.ICE15
PokemonTypeId.DRAGON16
PokemonTypeId.DARK17
PokemonTypeId.FAIRY18
PokemonTypeId.UNKNOWN10001
PokemonTypeId.SHADOW10002