@lucasmod/pokemon.js 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +96 -58
- package/docs/index.html +187 -84
- package/docs/styles.css +761 -106
- package/package.json +4 -4
- package/src/PokeAPI/get_ability.js +17 -17
- package/src/PokeAPI/get_all.js +9 -9
- package/src/PokeAPI/get_evolution_line.js +18 -18
- package/src/PokeAPI/get_generation.js +11 -11
- package/src/PokeAPI/get_item.js +13 -13
- package/src/PokeAPI/get_move.js +13 -13
- package/src/PokeAPI/get_nature.js +13 -13
- package/src/PokeAPI/get_pokemon.js +13 -13
- package/src/PokeAPI/get_pokemon_species.js +13 -13
- package/src/PokeAPI/get_region.js +12 -12
- package/src/PokeAPI/get_type.js +17 -17
- package/src/index.js +24 -24
- package/src/utils/filter_data.js +12 -12
- package/src/utils/format.js +2 -2
- package/src/utils/get.js +28 -28
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"test": "node ./module_test/test.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "@lucasmod/pokemon.js",
|
|
6
|
-
"version": "2.1.
|
|
6
|
+
"version": "2.1.5",
|
|
7
7
|
"description": "Versão corrigida do pokemon.js com suporte a ESM e créditos para lucasmod",
|
|
8
8
|
"author": "lucasmod",
|
|
9
9
|
"license": "ISC",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"main": "./src/index.js",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/
|
|
14
|
+
"url": "git+https://github.com/Otakump4/pokemon.js.git"
|
|
15
15
|
},
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/Otakump4/pokemon.js/issues"
|
|
18
18
|
},
|
|
19
|
-
"homepage": "
|
|
19
|
+
"homepage": "Otakump4.github.io/pokemon.js/",
|
|
20
20
|
"keywords": [
|
|
21
21
|
"pokemon",
|
|
22
22
|
"pokeapi",
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import filter_data from '../utils/filter_data.js';
|
|
2
|
-
import format_name from '../utils/format.js';
|
|
3
|
-
import get from '../utils/get.js'
|
|
4
|
-
|
|
5
|
-
/** Returns an Array of the pokémon's abilities or returns data for the ability in JSON format.
|
|
6
|
-
* @param {String | Number} name The ability or pokémon name.
|
|
7
|
-
* @param {boolean} is_pokemon Optional. Default is false.
|
|
8
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
9
|
-
* @returns {Promise<Object>} */
|
|
10
|
-
export default async function get_ability(name, is_pokemon = false, fields = []) {
|
|
11
|
-
name = format_name(name);
|
|
12
|
-
const data = is_pokemon ? await get(`pokemon/${name}`) : await get(`ability/${ability_name}`);
|
|
13
|
-
|
|
14
|
-
if (is_pokemon)
|
|
15
|
-
return data ? data['abilities'] : null;
|
|
16
|
-
|
|
17
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from '../utils/filter_data.js';
|
|
2
|
+
import format_name from '../utils/format.js';
|
|
3
|
+
import get from '../utils/get.js'
|
|
4
|
+
|
|
5
|
+
/** Returns an Array of the pokémon's abilities or returns data for the ability in JSON format.
|
|
6
|
+
* @param {String | Number} name The ability or pokémon name.
|
|
7
|
+
* @param {boolean} is_pokemon Optional. Default is false.
|
|
8
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
9
|
+
* @returns {Promise<Object>} */
|
|
10
|
+
export default async function get_ability(name, is_pokemon = false, fields = []) {
|
|
11
|
+
name = format_name(name);
|
|
12
|
+
const data = is_pokemon ? await get(`pokemon/${name}`) : await get(`ability/${ability_name}`);
|
|
13
|
+
|
|
14
|
+
if (is_pokemon)
|
|
15
|
+
return data ? data['abilities'] : null;
|
|
16
|
+
|
|
17
|
+
return data ? filter_data(data, fields) : null;
|
|
18
18
|
}
|
package/src/PokeAPI/get_all.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import get from "../utils/get.js";
|
|
2
|
-
|
|
3
|
-
/** Returns an Array containing names of all the specified resource type.
|
|
4
|
-
* @param {'item'|'pokemon'|'ability'|'type'|'move'|'nature'|'region'} type
|
|
5
|
-
* @returns {Promise<Array>} */
|
|
6
|
-
export default async function get_all(type = 'pokemon') {
|
|
7
|
-
const data = await get(`${type}?limit=100000&offset=0`);
|
|
8
|
-
|
|
9
|
-
return data ? data['results'].map(i => i.name) : null;
|
|
1
|
+
import get from "../utils/get.js";
|
|
2
|
+
|
|
3
|
+
/** Returns an Array containing names of all the specified resource type.
|
|
4
|
+
* @param {'item'|'pokemon'|'ability'|'type'|'move'|'nature'|'region'} type
|
|
5
|
+
* @returns {Promise<Array>} */
|
|
6
|
+
export default async function get_all(type = 'pokemon') {
|
|
7
|
+
const data = await get(`${type}?limit=100000&offset=0`);
|
|
8
|
+
|
|
9
|
+
return data ? data['results'].map(i => i.name) : null;
|
|
10
10
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import filter_data from '../utils/filter_data.js';
|
|
2
|
-
import get from '../utils/get.js'
|
|
3
|
-
import get_pokemon_species from './get_pokemon_species.js'
|
|
4
|
-
|
|
5
|
-
/** Returns data for the given pokémon.
|
|
6
|
-
* @param {String} pokemon Pokémon name or Pokédex #
|
|
7
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
-
* @returns {Promise<Object>} */
|
|
9
|
-
export default async function get_evolution_line(pokemon, fields = []) {
|
|
10
|
-
const SPECIES = await get_pokemon_species(pokemon);
|
|
11
|
-
|
|
12
|
-
if (!SPECIES)
|
|
13
|
-
return null;
|
|
14
|
-
|
|
15
|
-
const EVO_CHAIN = SPECIES.evolution_chain.url.split('/')[6];
|
|
16
|
-
const data = await get(`evolution-chain/${EVO_CHAIN}`);
|
|
17
|
-
|
|
18
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from '../utils/filter_data.js';
|
|
2
|
+
import get from '../utils/get.js'
|
|
3
|
+
import get_pokemon_species from './get_pokemon_species.js'
|
|
4
|
+
|
|
5
|
+
/** Returns data for the given pokémon.
|
|
6
|
+
* @param {String} pokemon Pokémon name or Pokédex #
|
|
7
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
+
* @returns {Promise<Object>} */
|
|
9
|
+
export default async function get_evolution_line(pokemon, fields = []) {
|
|
10
|
+
const SPECIES = await get_pokemon_species(pokemon);
|
|
11
|
+
|
|
12
|
+
if (!SPECIES)
|
|
13
|
+
return null;
|
|
14
|
+
|
|
15
|
+
const EVO_CHAIN = SPECIES.evolution_chain.url.split('/')[6];
|
|
16
|
+
const data = await get(`evolution-chain/${EVO_CHAIN}`);
|
|
17
|
+
|
|
18
|
+
return data ? filter_data(data, fields) : null;
|
|
19
19
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import filter_data from "../utils/filter_data.js";
|
|
2
|
-
import get from "../utils/get.js";
|
|
3
|
-
|
|
4
|
-
/** Returns data on the generation in JSON format.
|
|
5
|
-
* @param {Number} generation
|
|
6
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
7
|
-
* @returns {Promise<Object>} */
|
|
8
|
-
export default async function get_generation(generation, fields = []) {
|
|
9
|
-
const data = await get(`generation/${generation}`);
|
|
10
|
-
|
|
11
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from "../utils/filter_data.js";
|
|
2
|
+
import get from "../utils/get.js";
|
|
3
|
+
|
|
4
|
+
/** Returns data on the generation in JSON format.
|
|
5
|
+
* @param {Number} generation
|
|
6
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
7
|
+
* @returns {Promise<Object>} */
|
|
8
|
+
export default async function get_generation(generation, fields = []) {
|
|
9
|
+
const data = await get(`generation/${generation}`);
|
|
10
|
+
|
|
11
|
+
return data ? filter_data(data, fields) : null;
|
|
12
12
|
}
|
package/src/PokeAPI/get_item.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import filter_data from "../utils/filter_data.js";
|
|
2
|
-
import format_name from "../utils/format.js";
|
|
3
|
-
import get from "../utils/get.js";
|
|
4
|
-
|
|
5
|
-
/** Returns data on the item in JSON format.
|
|
6
|
-
* @param {String} item_name
|
|
7
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
-
* @returns {Promise<Object>} */
|
|
9
|
-
export default async function get_item(item_name, fields = []) {
|
|
10
|
-
item_name = format_name(item_name);
|
|
11
|
-
const data = await get(`item/${item_name}`);
|
|
12
|
-
|
|
13
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from "../utils/filter_data.js";
|
|
2
|
+
import format_name from "../utils/format.js";
|
|
3
|
+
import get from "../utils/get.js";
|
|
4
|
+
|
|
5
|
+
/** Returns data on the item in JSON format.
|
|
6
|
+
* @param {String} item_name
|
|
7
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
+
* @returns {Promise<Object>} */
|
|
9
|
+
export default async function get_item(item_name, fields = []) {
|
|
10
|
+
item_name = format_name(item_name);
|
|
11
|
+
const data = await get(`item/${item_name}`);
|
|
12
|
+
|
|
13
|
+
return data ? filter_data(data, fields) : null;
|
|
14
14
|
}
|
package/src/PokeAPI/get_move.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import filter_data from "../utils/filter_data.js";
|
|
2
|
-
import format_name from "../utils/format.js";
|
|
3
|
-
import get from "../utils/get.js";
|
|
4
|
-
|
|
5
|
-
/** Returns data on the move in JSON fromat.
|
|
6
|
-
* @param {String} move_name
|
|
7
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
-
* @returns {Promise<Object>} */
|
|
9
|
-
export default async function get_move(move_name, fields = []) {
|
|
10
|
-
move_name = format_name(move);
|
|
11
|
-
const data = await get(`move/${move_name}`);
|
|
12
|
-
|
|
13
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from "../utils/filter_data.js";
|
|
2
|
+
import format_name from "../utils/format.js";
|
|
3
|
+
import get from "../utils/get.js";
|
|
4
|
+
|
|
5
|
+
/** Returns data on the move in JSON fromat.
|
|
6
|
+
* @param {String} move_name
|
|
7
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
+
* @returns {Promise<Object>} */
|
|
9
|
+
export default async function get_move(move_name, fields = []) {
|
|
10
|
+
move_name = format_name(move);
|
|
11
|
+
const data = await get(`move/${move_name}`);
|
|
12
|
+
|
|
13
|
+
return data ? filter_data(data, fields) : null;
|
|
14
14
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import filter_data from '../utils/filter_data.js';
|
|
2
|
-
import format_name from '../utils/format.js';
|
|
3
|
-
import get from '../utils/get.js'
|
|
4
|
-
|
|
5
|
-
/** Returns an Object that contains the increased and decreased stat caused by the nature.
|
|
6
|
-
* @param {'hardy'|'bold'|'modest'|'calm'|'timid'|'lonely'|'docile'|'mild'|'gentle'|'hasty'|'adamant'|'impish'|'bashful'|'careful'|'rash'|'jolly'|'naughty'|'lax'|'quirky'|'naive'|'brave'|'relaxed'|'quiet'|'sassy'|'serious'} nature_name
|
|
7
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
-
* @returns {Promise<Object>} */
|
|
9
|
-
export default async function get_nature(nature_name, fields = []) {
|
|
10
|
-
nature_name = format_name(nature_name);
|
|
11
|
-
const data = await get(`nature/${nature_name}`);
|
|
12
|
-
|
|
13
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from '../utils/filter_data.js';
|
|
2
|
+
import format_name from '../utils/format.js';
|
|
3
|
+
import get from '../utils/get.js'
|
|
4
|
+
|
|
5
|
+
/** Returns an Object that contains the increased and decreased stat caused by the nature.
|
|
6
|
+
* @param {'hardy'|'bold'|'modest'|'calm'|'timid'|'lonely'|'docile'|'mild'|'gentle'|'hasty'|'adamant'|'impish'|'bashful'|'careful'|'rash'|'jolly'|'naughty'|'lax'|'quirky'|'naive'|'brave'|'relaxed'|'quiet'|'sassy'|'serious'} nature_name
|
|
7
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
+
* @returns {Promise<Object>} */
|
|
9
|
+
export default async function get_nature(nature_name, fields = []) {
|
|
10
|
+
nature_name = format_name(nature_name);
|
|
11
|
+
const data = await get(`nature/${nature_name}`);
|
|
12
|
+
|
|
13
|
+
return data ? filter_data(data, fields) : null;
|
|
14
14
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import filter_data from '../utils/filter_data.js';
|
|
2
|
-
import format_name from '../utils/format.js';
|
|
3
|
-
import get from '../utils/get.js'
|
|
4
|
-
|
|
5
|
-
/** Returns data for the given pokémon.
|
|
6
|
-
* @param {String} pokemon Pokémon name or Pokédex #
|
|
7
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
-
* @returns {Promise<Object>} */
|
|
9
|
-
export default async function get_pokemon(pokemon, fields = []) {
|
|
10
|
-
pokemon = format_name(pokemon);
|
|
11
|
-
const data = await get(`pokemon/${pokemon}`);
|
|
12
|
-
|
|
13
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from '../utils/filter_data.js';
|
|
2
|
+
import format_name from '../utils/format.js';
|
|
3
|
+
import get from '../utils/get.js'
|
|
4
|
+
|
|
5
|
+
/** Returns data for the given pokémon.
|
|
6
|
+
* @param {String} pokemon Pokémon name or Pokédex #
|
|
7
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
+
* @returns {Promise<Object>} */
|
|
9
|
+
export default async function get_pokemon(pokemon, fields = []) {
|
|
10
|
+
pokemon = format_name(pokemon);
|
|
11
|
+
const data = await get(`pokemon/${pokemon}`);
|
|
12
|
+
|
|
13
|
+
return data ? filter_data(data, fields) : null;
|
|
14
14
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import filter_data from '../utils/filter_data.js';
|
|
2
|
-
import format_name from '../utils/format.js';
|
|
3
|
-
import get from '../utils/get.js'
|
|
4
|
-
|
|
5
|
-
/** Returns data for the given pokémon.
|
|
6
|
-
* @param {String} pokemon Pokémon name or Pokédex #
|
|
7
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
-
* @returns {Promise<Object>} */
|
|
9
|
-
export default async function get_pokemon_species(pokemon, fields = []) {
|
|
10
|
-
pokemon = format_name(pokemon);
|
|
11
|
-
const data = await get(`pokemon-species/${pokemon}`);
|
|
12
|
-
|
|
13
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from '../utils/filter_data.js';
|
|
2
|
+
import format_name from '../utils/format.js';
|
|
3
|
+
import get from '../utils/get.js'
|
|
4
|
+
|
|
5
|
+
/** Returns data for the given pokémon.
|
|
6
|
+
* @param {String} pokemon Pokémon name or Pokédex #
|
|
7
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
8
|
+
* @returns {Promise<Object>} */
|
|
9
|
+
export default async function get_pokemon_species(pokemon, fields = []) {
|
|
10
|
+
pokemon = format_name(pokemon);
|
|
11
|
+
const data = await get(`pokemon-species/${pokemon}`);
|
|
12
|
+
|
|
13
|
+
return data ? filter_data(data, fields) : null;
|
|
14
14
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import format_name from "../utils/format.js";
|
|
2
|
-
import get from "../utils/get.js";
|
|
3
|
-
|
|
4
|
-
/** Returns data on the region in JSON format.
|
|
5
|
-
* @param {'kanto'|'johto'|'hoenn'|'sinnoh'|'unova'|'kalos'|'alola'|'galar'|'hisui'|'paldea'} region
|
|
6
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
7
|
-
* @returns {Promise<JSON>} */
|
|
8
|
-
export default async function get_region(region, fields = []) {
|
|
9
|
-
region = format_name(region);
|
|
10
|
-
const data = await get(`region/${region}`);
|
|
11
|
-
|
|
12
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import format_name from "../utils/format.js";
|
|
2
|
+
import get from "../utils/get.js";
|
|
3
|
+
|
|
4
|
+
/** Returns data on the region in JSON format.
|
|
5
|
+
* @param {'kanto'|'johto'|'hoenn'|'sinnoh'|'unova'|'kalos'|'alola'|'galar'|'hisui'|'paldea'} region
|
|
6
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
7
|
+
* @returns {Promise<JSON>} */
|
|
8
|
+
export default async function get_region(region, fields = []) {
|
|
9
|
+
region = format_name(region);
|
|
10
|
+
const data = await get(`region/${region}`);
|
|
11
|
+
|
|
12
|
+
return data ? filter_data(data, fields) : null;
|
|
13
13
|
}
|
package/src/PokeAPI/get_type.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import filter_data from '../utils/filter_data.js';
|
|
2
|
-
import format_name from '../utils/format.js';
|
|
3
|
-
import get from '../utils/get.js'
|
|
4
|
-
|
|
5
|
-
/** Returns an Array of the pokémon's types or returns data for the type in JSON format.
|
|
6
|
-
* @param {String | Number} name The type or pokémon name.
|
|
7
|
-
* @param {boolean} is_pokemon Optional. Default is false.
|
|
8
|
-
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
9
|
-
* @returns {Promise<Object> | Promise<Array>} */
|
|
10
|
-
export default async function get_type(name, is_pokemon = false, fields = []) {
|
|
11
|
-
name = format_name(name);
|
|
12
|
-
const data = is_pokemon ? await get(`pokemon/${name}`) : await get(`type/${name}`);
|
|
13
|
-
|
|
14
|
-
if (is_pokemon)
|
|
15
|
-
return data ? data['types'] : null;
|
|
16
|
-
|
|
17
|
-
return data ? filter_data(data, fields) : null;
|
|
1
|
+
import filter_data from '../utils/filter_data.js';
|
|
2
|
+
import format_name from '../utils/format.js';
|
|
3
|
+
import get from '../utils/get.js'
|
|
4
|
+
|
|
5
|
+
/** Returns an Array of the pokémon's types or returns data for the type in JSON format.
|
|
6
|
+
* @param {String | Number} name The type or pokémon name.
|
|
7
|
+
* @param {boolean} is_pokemon Optional. Default is false.
|
|
8
|
+
* @param {String[]} fields Optional. An array of property names to include in the returned object.
|
|
9
|
+
* @returns {Promise<Object> | Promise<Array>} */
|
|
10
|
+
export default async function get_type(name, is_pokemon = false, fields = []) {
|
|
11
|
+
name = format_name(name);
|
|
12
|
+
const data = is_pokemon ? await get(`pokemon/${name}`) : await get(`type/${name}`);
|
|
13
|
+
|
|
14
|
+
if (is_pokemon)
|
|
15
|
+
return data ? data['types'] : null;
|
|
16
|
+
|
|
17
|
+
return data ? filter_data(data, fields) : null;
|
|
18
18
|
}
|
package/src/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import get_ability from './PokeAPI/get_ability.js';
|
|
2
|
-
import get_evolution_line from './PokeAPI/get_evolution_line.js';
|
|
3
|
-
import get_generation from './PokeAPI/get_generation.js';
|
|
4
|
-
import get_item from './PokeAPI/get_item.js';
|
|
5
|
-
import get_move from './PokeAPI/get_move.js';
|
|
6
|
-
import get_nature from './PokeAPI/get_nature.js';
|
|
7
|
-
import get_pokemon from './PokeAPI/get_pokemon.js';
|
|
8
|
-
import get_pokemon_species from './PokeAPI/get_pokemon_species.js';
|
|
9
|
-
import get_type from './PokeAPI/get_type.js';
|
|
10
|
-
import get_region from './PokeAPI/get_region.js';
|
|
11
|
-
import get_all from './PokeAPI/get_all.js';
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
get_pokemon,
|
|
15
|
-
get_pokemon_species,
|
|
16
|
-
get_evolution_line,
|
|
17
|
-
get_type,
|
|
18
|
-
get_ability,
|
|
19
|
-
get_nature,
|
|
20
|
-
get_move,
|
|
21
|
-
get_item,
|
|
22
|
-
get_generation,
|
|
23
|
-
get_region,
|
|
24
|
-
get_all
|
|
1
|
+
import get_ability from './PokeAPI/get_ability.js';
|
|
2
|
+
import get_evolution_line from './PokeAPI/get_evolution_line.js';
|
|
3
|
+
import get_generation from './PokeAPI/get_generation.js';
|
|
4
|
+
import get_item from './PokeAPI/get_item.js';
|
|
5
|
+
import get_move from './PokeAPI/get_move.js';
|
|
6
|
+
import get_nature from './PokeAPI/get_nature.js';
|
|
7
|
+
import get_pokemon from './PokeAPI/get_pokemon.js';
|
|
8
|
+
import get_pokemon_species from './PokeAPI/get_pokemon_species.js';
|
|
9
|
+
import get_type from './PokeAPI/get_type.js';
|
|
10
|
+
import get_region from './PokeAPI/get_region.js';
|
|
11
|
+
import get_all from './PokeAPI/get_all.js';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
get_pokemon,
|
|
15
|
+
get_pokemon_species,
|
|
16
|
+
get_evolution_line,
|
|
17
|
+
get_type,
|
|
18
|
+
get_ability,
|
|
19
|
+
get_nature,
|
|
20
|
+
get_move,
|
|
21
|
+
get_item,
|
|
22
|
+
get_generation,
|
|
23
|
+
get_region,
|
|
24
|
+
get_all
|
|
25
25
|
};
|
package/src/utils/filter_data.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export default function filter_data(data, fields) {
|
|
2
|
-
if (fields.length == 0)
|
|
3
|
-
return data;
|
|
4
|
-
|
|
5
|
-
const filteredData = {};
|
|
6
|
-
for (const field of fields) {
|
|
7
|
-
if (data.hasOwnProperty(field)) {
|
|
8
|
-
filteredData[field] = data[field];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return filteredData;
|
|
1
|
+
export default function filter_data(data, fields) {
|
|
2
|
+
if (fields.length == 0)
|
|
3
|
+
return data;
|
|
4
|
+
|
|
5
|
+
const filteredData = {};
|
|
6
|
+
for (const field of fields) {
|
|
7
|
+
if (data.hasOwnProperty(field)) {
|
|
8
|
+
filteredData[field] = data[field];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return filteredData;
|
|
13
13
|
}
|
package/src/utils/format.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default function format_name(name) {
|
|
2
|
-
return name.includes(" ") ? name.replaceAll(" ", "-") : name;
|
|
1
|
+
export default function format_name(name) {
|
|
2
|
+
return name.includes(" ") ? name.replaceAll(" ", "-") : name;
|
|
3
3
|
}
|
package/src/utils/get.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import fetch from "node-fetch";
|
|
2
|
-
|
|
3
|
-
const POKE_BASE_URL = 'https://pokeapi.co/api/v2'
|
|
4
|
-
const POGO_BASE_URL = 'https://pogoapi.net/api/v1/'
|
|
5
|
-
|
|
6
|
-
/** Gets data from the PokeAPI
|
|
7
|
-
* @param {String} endpoint
|
|
8
|
-
* @param {String} params
|
|
9
|
-
* @param {'POKE' | 'POGO'} api
|
|
10
|
-
* @returns {Promise<Object> | null} */
|
|
11
|
-
export default async function get(endpoint, params='', api='POKE') {
|
|
12
|
-
const BASE_URL = api == 'POKE' ? POKE_BASE_URL : POGO_BASE_URL
|
|
13
|
-
|
|
14
|
-
const URL = params ? `${BASE_URL}/${endpoint}?${params}` : `${BASE_URL}/${endpoint}`;
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const res = await fetch(URL, { method: "GET" });
|
|
18
|
-
|
|
19
|
-
if (!res.ok) {
|
|
20
|
-
console.error(`HTTP error! Status: ${res.status}`);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return await res.json();
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error(error);
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
1
|
+
import fetch from "node-fetch";
|
|
2
|
+
|
|
3
|
+
const POKE_BASE_URL = 'https://pokeapi.co/api/v2'
|
|
4
|
+
const POGO_BASE_URL = 'https://pogoapi.net/api/v1/'
|
|
5
|
+
|
|
6
|
+
/** Gets data from the PokeAPI
|
|
7
|
+
* @param {String} endpoint
|
|
8
|
+
* @param {String} params
|
|
9
|
+
* @param {'POKE' | 'POGO'} api
|
|
10
|
+
* @returns {Promise<Object> | null} */
|
|
11
|
+
export default async function get(endpoint, params='', api='POKE') {
|
|
12
|
+
const BASE_URL = api == 'POKE' ? POKE_BASE_URL : POGO_BASE_URL
|
|
13
|
+
|
|
14
|
+
const URL = params ? `${BASE_URL}/${endpoint}?${params}` : `${BASE_URL}/${endpoint}`;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const res = await fetch(URL, { method: "GET" });
|
|
18
|
+
|
|
19
|
+
if (!res.ok) {
|
|
20
|
+
console.error(`HTTP error! Status: ${res.status}`);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return await res.json();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(error);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
29
|
}
|