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
| Parameter | Type | Required | Description |
|---|---|---|---|
typeId | PokemonTypeId | Yes | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
typeIndex | PokemonTypesArrayIndex | Yes | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
typeIndex | PokemonTypesArrayIndex | Yes | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
typeName | PokemonTypeName | Yes | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
typeName | PokemonTypeName | Yes | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
typeId | PokemonTypeId | Yes | The 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
| Name | Value |
|---|---|
id2name() | formatTypeIdToName() |
id2index() | formatTypeIdToIndex() |
index2id() | formatTypeIndexToId() |
index2name() | formatTypeIndexToName() |
name2id() | formatTypeNameToId() |
name2index() | formatTypeNameToIndex() |
PokemonTypeId
An enum for PokéAPI Type resources' ids.
| Types |
|---|
| Enum |
Properties
| Name | Value |
|---|---|
PokemonTypeId.NORMAL | 1 |
PokemonTypeId.FIGHTING | 2 |
PokemonTypeId.FLYING | 3 |
PokemonTypeId.POISON | 4 |
PokemonTypeId.GROUND | 5 |
PokemonTypeId.ROCK | 6 |
PokemonTypeId.BUG | 7 |
PokemonTypeId.GHOST | 8 |
PokemonTypeId.STEEL | 9 |
PokemonTypeId.FIRE | 10 |
PokemonTypeId.WATER | 11 |
PokemonTypeId.GRASS | 12 |
PokemonTypeId.ELECTRIC | 13 |
PokemonTypeId.PSYCHIC | 14 |
PokemonTypeId.ICE | 15 |
PokemonTypeId.DRAGON | 16 |
PokemonTypeId.DARK | 17 |
PokemonTypeId.FAIRY | 18 |
PokemonTypeId.UNKNOWN | 10001 |
PokemonTypeId.SHADOW | 10002 |