Skip to content

Commit df52421

Browse files
committed
feat: duplicate root methods
1 parent 3cf6690 commit df52421

4 files changed

Lines changed: 108 additions & 102 deletions

File tree

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/endpoints.json

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
[
2-
["getBerry", "name", "/berry/:id/"],
3-
["getBerryFirmness", "name", "/berry-firmness/:id/"],
4-
["getBerryFlavor", "name", "/berry-flavor/:id/"],
5-
["getContestType", "name", "/contest-type/:id/"],
6-
["getContestEffect", "id", "/contest-effect/:id/"],
7-
["getSuperContestEffect", "id", "/super-contest-effect/:id/"],
8-
["getEncounterMethod", "name", "/encounter-method/:id/"],
9-
["getEncounterCondition", "name", "/encounter-condition/:id/"],
10-
["getEncounterConditionValue", "name", "/encounter-condition-value/:id/"],
11-
["getEvolutionChain", "id", "/evolution-chain/:id/"],
12-
["getEvolutionTrigger", "name", "/evolution-trigger/:id/"],
13-
["getGeneration", "name", "/generation/:id/"],
14-
["getPokedex", "name", "/pokedex/:id/"],
15-
["getVersion", "name", "/version/:id/"],
16-
["getVersionGroup", "name", "/version-group/:id/"],
17-
["getItem", "name", "/item/:id/"],
18-
["getItemAttribute", "name", "/item-attribute/:id/"],
19-
["getItemCategory", "name", "/item-category/:id/"],
20-
["getItemFlingEffect", "name", "/item-fling-effect/:id/"],
21-
["getItemPocket", "name", "/item-pocket/:id/"],
22-
["getMachine", "id", "/machine/:id/"],
23-
["getMove", "name", "/move/:id/"],
24-
["getMoveAilment", "name", "/move-ailment/:id/"],
25-
["getMoveBattleStyle", "name", "/move-battle-style/:id/"],
26-
["getMoveCategory", "name", "/move-category/:id/"],
27-
["getMoveDamageClass", "name", "/move-damage-class/:id/"],
28-
["getMoveLearnMethod", "name", "/move-learn-method/:id/"],
29-
["getMoveTarget", "name", "/move-target/:id/"],
30-
["getLocation", "name", "/location/:id/"],
31-
["getLocationArea", "name", "/location-area/:id/"],
32-
["getPalParkArea", "name", "/pal-park-area/:id/"],
33-
["getRegion", "name", "/region/:id/"],
34-
["getAbility", "name", "/ability/:id/"],
35-
["getCharacteristic", "id", "/characteristic/:id/"],
36-
["getEggGroup", "name", "/egg-group/:id/"],
37-
["getGender", "name", "/gender/:id/"],
38-
["getGrowthRate", "name", "/growth-rate/:id/"],
39-
["getNature", "name", "/nature/:id/"],
40-
["getPokeathlonStat", "name", "/pokeathlon-stat/:id/"],
41-
["getPokemon", "name", "/pokemon/:id/"],
42-
["getPokemonEncounterAreas", "name", "/pokemon/:id/encounters/"],
43-
["getPokemonColor", "name", "/pokemon-color/:id/"],
44-
["getPokemonForm", "name", "/pokemon-form/:id/"],
45-
["getPokemonHabitat", "name", "/pokemon-habitat/:id/"],
46-
["getPokemonShape", "name", "/pokemon-shape/:id/"],
47-
["getPokemonSpecies", "name", "/pokemon-species/:id/"],
48-
["getStat", "name", "/stat/:id/"],
49-
["getType", "name", "/type/:id/"],
50-
["getLanguage", "name", "/language/:id/"]
2+
["getBerry", "name", "berry/:id/"],
3+
["getBerryFirmness", "name", "berry-firmness/:id/"],
4+
["getBerryFlavor", "name", "berry-flavor/:id/"],
5+
["getContestType", "name", "contest-type/:id/"],
6+
["getContestEffect", "id", "contest-effect/:id/"],
7+
["getSuperContestEffect", "id", "super-contest-effect/:id/"],
8+
["getEncounterMethod", "name", "encounter-method/:id/"],
9+
["getEncounterCondition", "name", "encounter-condition/:id/"],
10+
["getEncounterConditionValue", "name", "encounter-condition-value/:id/"],
11+
["getEvolutionChain", "id", "evolution-chain/:id/"],
12+
["getEvolutionTrigger", "name", "evolution-trigger/:id/"],
13+
["getGeneration", "name", "generation/:id/"],
14+
["getPokedex", "name", "pokedex/:id/"],
15+
["getVersion", "name", "version/:id/"],
16+
["getVersionGroup", "name", "version-group/:id/"],
17+
["getItem", "name", "item/:id/"],
18+
["getItemAttribute", "name", "item-attribute/:id/"],
19+
["getItemCategory", "name", "item-category/:id/"],
20+
["getItemFlingEffect", "name", "item-fling-effect/:id/"],
21+
["getItemPocket", "name", "item-pocket/:id/"],
22+
["getMachine", "id", "machine/:id/"],
23+
["getMove", "name", "move/:id/"],
24+
["getMoveAilment", "name", "move-ailment/:id/"],
25+
["getMoveBattleStyle", "name", "move-battle-style/:id/"],
26+
["getMoveCategory", "name", "move-category/:id/"],
27+
["getMoveDamageClass", "name", "move-damage-class/:id/"],
28+
["getMoveLearnMethod", "name", "move-learn-method/:id/"],
29+
["getMoveTarget", "name", "move-target/:id/"],
30+
["getLocation", "name", "location/:id/"],
31+
["getLocationArea", "name", "location-area/:id/"],
32+
["getPalParkArea", "name", "pal-park-area/:id/"],
33+
["getRegion", "name", "region/:id/"],
34+
["getAbility", "name", "ability/:id/"],
35+
["getCharacteristic", "id", "characteristic/:id/"],
36+
["getEggGroup", "name", "egg-group/:id/"],
37+
["getGender", "name", "gender/:id/"],
38+
["getGrowthRate", "name", "growth-rate/:id/"],
39+
["getNature", "name", "nature/:id/"],
40+
["getPokeathlonStat", "name", "pokeathlon-stat/:id/"],
41+
["getPokemon", "name", "pokemon/:id/"],
42+
["getPokemonEncounterAreas", "name", "pokemon/:id/encounters/"],
43+
["getPokemonColor", "name", "pokemon-color/:id/"],
44+
["getPokemonForm", "name", "pokemon-form/:id/"],
45+
["getPokemonHabitat", "name", "pokemon-habitat/:id/"],
46+
["getPokemonShape", "name", "pokemon-shape/:id/"],
47+
["getPokemonSpecies", "name", "pokemon-species/:id/"],
48+
["getStat", "name", "stat/:id/"],
49+
["getType", "name", "type/:id/"],
50+
["getLanguage", "name", "language/:id/"]
5151
]

src/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export class Pokedex {
3737
})
3838

3939
rootEndpoints.forEach(rootEndpoint => {
40-
this[rootEndpoint[0]] = config => {
40+
const rootEndpointFullName = buildRootEndpointFullName(rootEndpoint)
41+
this[rootEndpointFullName] = config => {
4142
var limit = this.config.limit
4243
var offset = this.config.offset
4344
if (config) {
@@ -50,6 +51,7 @@ export class Pokedex {
5051
}
5152
return loadResource(this.config, `${this.config.versionPath}${rootEndpoint[1]}?limit=${limit}&offset=${offset}`)
5253
}
54+
this[rootEndpoint[0]] = this[rootEndpointFullName]
5355
})
5456

5557
if (this.config.cacheImages) {
@@ -91,7 +93,11 @@ function buildEndpointFullName(endpoint) {
9193
}
9294

9395
function buildEndpointName(endpoint) {
94-
return `${endpoint[0]}}`
96+
return `${endpoint[0]}`
97+
}
98+
99+
function buildRootEndpointFullName(endpoint) {
100+
return `${endpoint[0]}List`
95101
}
96102

97103
function capitalize([first,...rest]) {

src/rootEndpoints.json

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
[
2-
["getEndpointsList", ""],
3-
["getBerriesList", "berry/"],
4-
["getBerriesFirmnesssList", "berry-firmness/"],
5-
["getBerriesFlavorsList", "berry-flavor/"],
6-
["getContestTypesList", "contest-type/"],
7-
["getContestEffectsList", "contest-effect/"],
8-
["getSuperContestEffectsList", "super-contest-effect/"],
9-
["getEncounterMethodsList", "encounter-method/"],
10-
["getEncounterConditionsList", "encounter-condition/"],
11-
["getEncounterConditionValuesList", "encounter-condition-value/"],
12-
["getEvolutionChainsList", "evolution-chain/"],
13-
["getEvolutionTriggersList", "evolution-trigger/"],
14-
["getGenerationsList", "generation/"],
15-
["getPokedexsList", "pokedex/"],
16-
["getVersionsList", "version/"],
17-
["getVersionGroupsList", "version-group/"],
18-
["getItemsList", "item/"],
19-
["getItemAttributesList", "item-attribute/"],
20-
["getItemCategoriesList", "item-category/"],
21-
["getItemFlingEffectsList", "item-fling-effect/"],
22-
["getItemPocketsList", "item-pocket/"],
23-
["getMachinesList", "machine/"],
24-
["getMovesList", "move/"],
25-
["getMoveAilmentsList", "move-ailment/"],
26-
["getMoveBattleStylesList", "move-battle-style/"],
27-
["getMoveCategoriesList", "move-category/"],
28-
["getMoveDamageClassesList", "move-damage-class/"],
29-
["getMoveLearnMethodsList", "move-learn-method/"],
30-
["getMoveTargetsList", "move-target/"],
31-
["getLocationsList", "location/"],
32-
["getLocationAreasList", "location-area/"],
33-
["getPalParkAreasList", "pal-park-area/"],
34-
["getRegionsList", "region/"],
35-
["getAbilitiesList", "ability/"],
36-
["getCharacteristicsList", "characteristic/"],
37-
["getEggGroupsList", "egg-group/"],
38-
["getGendersList", "gender/"],
39-
["getGrowthRatesList", "growth-rate/"],
40-
["getNaturesList", "nature/"],
41-
["getPokeathlonStatsList", "pokeathlon-stat/"],
42-
["getPokemonsList", "pokemon/"],
43-
["getPokemonColorsList", "pokemon-color/"],
44-
["getPokemonFormsList", "pokemon-form/"],
45-
["getPokemonHabitatsList", "pokemon-habitat/"],
46-
["getPokemonShapesList", "pokemon-shape/"],
47-
["getPokemonSpeciesList", "pokemon-species/"],
48-
["getStatsList", "stat/"],
49-
["getTypesList", "type/"],
50-
["getLanguagesList", "language/"]
2+
["getEndpoints", ""],
3+
["getBerries", "berry/"],
4+
["getBerriesFirmnesss", "berry-firmness/"],
5+
["getBerriesFlavors", "berry-flavor/"],
6+
["getContestTypes", "contest-type/"],
7+
["getContestEffects", "contest-effect/"],
8+
["getSuperContestEffects", "super-contest-effect/"],
9+
["getEncounterMethods", "encounter-method/"],
10+
["getEncounterConditions", "encounter-condition/"],
11+
["getEncounterConditionValues", "encounter-condition-value/"],
12+
["getEvolutionChains", "evolution-chain/"],
13+
["getEvolutionTriggers", "evolution-trigger/"],
14+
["getGenerations", "generation/"],
15+
["getPokedexs", "pokedex/"],
16+
["getVersions", "version/"],
17+
["getVersionGroups", "version-group/"],
18+
["getItems", "item/"],
19+
["getItemAttributes", "item-attribute/"],
20+
["getItemCategories", "item-category/"],
21+
["getItemFlingEffects", "item-fling-effect/"],
22+
["getItemPockets", "item-pocket/"],
23+
["getMachines", "machine/"],
24+
["getMoves", "move/"],
25+
["getMoveAilments", "move-ailment/"],
26+
["getMoveBattleStyles", "move-battle-style/"],
27+
["getMoveCategories", "move-category/"],
28+
["getMoveDamageClasses", "move-damage-class/"],
29+
["getMoveLearnMethods", "move-learn-method/"],
30+
["getMoveTargets", "move-target/"],
31+
["getLocations", "location/"],
32+
["getLocationAreas", "location-area/"],
33+
["getPalParkAreas", "pal-park-area/"],
34+
["getRegions", "region/"],
35+
["getAbilities", "ability/"],
36+
["getCharacteristics", "characteristic/"],
37+
["getEggGroups", "egg-group/"],
38+
["getGenders", "gender/"],
39+
["getGrowthRates", "growth-rate/"],
40+
["getNatures", "nature/"],
41+
["getPokeathlonStats", "pokeathlon-stat/"],
42+
["getPokemons", "pokemon/"],
43+
["getPokemonColors", "pokemon-color/"],
44+
["getPokemonForms", "pokemon-form/"],
45+
["getPokemonHabitats", "pokemon-habitat/"],
46+
["getPokemonShapes", "pokemon-shape/"],
47+
["getPokemonSpecies", "pokemon-species/"],
48+
["getStats", "stat/"],
49+
["getTypes", "type/"],
50+
["getLanguages", "language/"]
5151
]

0 commit comments

Comments
 (0)