19 | The above image is served (once cached) by the local pokeapi-js-wrapper-sw.js SW. Check it out in the Developer Console (F12) by looking at the Network Panel and also at the Application Panel.
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const webpack = require('webpack');
3 | const CopyPlugin = require('copy-webpack-plugin');
4 |
5 | module.exports = {
6 | entry: './src/index.js',
7 | target: 'web',
8 | devtool: 'source-map',
9 | output: {
10 | path: path.resolve(__dirname, 'dist'),
11 | filename: 'index.js',
12 | libraryTarget: 'umd',
13 | library: 'Pokedex',
14 | globalObject: `(typeof self !== 'undefined' ? self : this)`
15 | },
16 | mode: 'production',
17 | plugins: [
18 | new CopyPlugin({
19 | patterns: [
20 | {
21 | from: 'src/pokeapi-js-wrapper-sw.js',
22 | to: 'pokeapi-js-wrapper-sw.js',
23 | toType: 'file'
24 | },
25 | {
26 | from: 'src/pokeapi-js-wrapper-sw.js',
27 | to: '../test/pokeapi-js-wrapper-sw.js',
28 | toType: 'file'
29 | }
30 | ]
31 | })
32 | ]
33 | };
34 |
--------------------------------------------------------------------------------
/src/pokeapi-js-wrapper-sw.js:
--------------------------------------------------------------------------------
1 | const imgRe = /https:\/\/raw\.githubusercontent\.com\/PokeAPI\/sprites\/[\/-\w\d]+\/[\d\w-]+\.(?:png|svg|gif)/
2 | const version = 1
3 |
4 | self.addEventListener('fetch', function (event) {
5 | if (event.request.url.match(imgRe)) {
6 | event.respondWith(caches.match(event.request).then(function (response) {
7 | if (response) {
8 | return response
9 | }
10 |
11 | return fetch(event.request).then(function (response) {
12 | if (event.request.url.match(imgRe)) {
13 | caches.open("pokeapi-js-wrapper-images-" + version).then(function (cache) {
14 | // The response is opaque, if it fails cache.add() will reject it
15 | cache.add(event.request.url)
16 | })
17 | }
18 | return response;
19 | }).catch(function (error) {
20 | console.error(error)
21 | })
22 | }))
23 | }
24 | })
25 |
26 | self.addEventListener('install', function(event) {
27 | self.skipWaiting()
28 | })
29 |
--------------------------------------------------------------------------------
/src/config.js:
--------------------------------------------------------------------------------
1 | class Config {
2 | constructor(config={}) {
3 | this.protocol = 'https'
4 | this.hostName = 'pokeapi.co'
5 | this.versionPath = '/api/v2/'
6 | this.offset = 0
7 | this.limit = 100000
8 | this.timeout = 10 * 1000 // 2 seconds
9 | this.cache = true
10 | this.cacheImages = false
11 |
12 | if (config.hasOwnProperty('protocol')) {
13 | this.protocol = config.protocol
14 | }
15 | if (config.hasOwnProperty('hostName')) {
16 | this.hostName = config.hostName
17 | }
18 | if (config.hasOwnProperty('versionPath')) {
19 | this.versionPath = config.versionPath
20 | }
21 | if (config.hasOwnProperty('offset')) {
22 | this.offset = config.offset - 1
23 | }
24 | if (config.hasOwnProperty('limit')) {
25 | this.limit = config.limit
26 | }
27 | if (config.hasOwnProperty('timeout')) {
28 | this.timeout = config.timeout
29 | }
30 | if (config.hasOwnProperty('cache')) {
31 | this.cache = config.cache
32 | }
33 | if (config.hasOwnProperty('cacheImages')) {
34 | this.cacheImages = config.cacheImages
35 | }
36 | }
37 | }
38 | export { Config }
39 |
--------------------------------------------------------------------------------
/test/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Mocha Tests
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pokeapi-js-wrapper",
3 | "version": "1.2.8",
4 | "description": "An API wrapper for PokeAPI",
5 | "main": "dist/index.js",
6 | "module": "src/index.js",
7 | "files": [
8 | "dist/index.js",
9 | "dist/pokeapi-js-wrapper-sw.js",
10 | "src/*",
11 | "index.d.ts"
12 | ],
13 | "scripts": {
14 | "build": "webpack",
15 | "build:watch": "webpack --watch",
16 | "clean": "rm -rf ./dist/*",
17 | "doctoc": "doctoc .",
18 | "test": "nyc --reporter=lcov mocha -r mock-local-storage -r source-map-support/register ./test/test.js --timeout 10000",
19 | "prepublish": "npm run build",
20 | "serve": "http-server ."
21 | },
22 | "repository": {
23 | "type": "git",
24 | "url": "git+https://github.com/PokeAPI/pokeapi-js-wrapper"
25 | },
26 | "keywords": [
27 | "pokedex",
28 | "pokemon",
29 | "nintendo",
30 | "promise",
31 | "pokeapi",
32 | "browser",
33 | "cache"
34 | ],
35 | "author": "Alessandro Pezzé (https://github.com/Naramsim)",
36 | "contributors": [],
37 | "license": "MPL-2.0",
38 | "bugs": {
39 | "url": "https://github.com/PokeAPI/pokeapi-js-wrapper/issues"
40 | },
41 | "homepage": "https://github.com/PokeAPI/pokeapi-js-wrapper#readme",
42 | "types": "./index.d.ts",
43 | "dependencies": {
44 | "axios": "^1.11.0",
45 | "localforage": "^1.10.0"
46 | },
47 | "devDependencies": {
48 | "chai": "^4.5.0",
49 | "chai-as-promised": "^7.1.2",
50 | "chai-things": "^0.2.0",
51 | "copy-webpack-plugin": "^13.0.0",
52 | "doctoc": "^2.2.1",
53 | "http-server": "^14.1.1",
54 | "mocha": "^11.7.1",
55 | "mock-local-storage": "^1.1.24",
56 | "nyc": "^17.1.0",
57 | "webpack": "^5.101.0",
58 | "webpack-cli": "^6.0.1"
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/getter.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import localForage from "localforage"
3 |
4 | const CACHE_PREFIX = "pokeapi-js-wrapper-"
5 |
6 | function loadResource(config, url) {
7 | return new Promise((resolve, reject) => {
8 | localForage.ready()
9 | .then(() => {
10 | localForage.getItem(`${CACHE_PREFIX}${url}`)
11 | .then(value => {
12 | if (value === null) {
13 | loadUrl(config, url).then(res => {resolve(res)})
14 | .catch(err => {reject(err)})
15 | } else {
16 | resolve(addCacheMark(value))
17 | }
18 | })
19 | .catch(err => {
20 | loadUrl(config, url).then(res => {resolve(res)})
21 | .catch(err => {reject(err)})
22 | })
23 | })
24 | .catch(err => {
25 | loadUrl(config, url).then(res => {resolve(res)})
26 | .catch(err => {reject(err)})
27 | })
28 | })
29 | }
30 |
31 | function loadUrl(config, url) {
32 | return new Promise((resolve, reject) => {
33 | let options = {
34 | baseURL: `${config.protocol}://${config.hostName}/`,
35 | timeout: config.timeout
36 | }
37 | axios.get(url, options)
38 | .then(response => {
39 | // if there was an error
40 | if (response.status >= 400) {
41 | reject(response)
42 | } else {
43 | // if everything was good
44 | // cache the object in browser memory
45 | // only if cache is true
46 | if (config.cache) {
47 | localForage.setItem(`${CACHE_PREFIX}${url}`, response.data)
48 | }
49 | resolve(response.data)
50 | }
51 | })
52 | .catch(err => { reject(err) })
53 | })
54 | }
55 |
56 | export { loadResource }
57 |
--------------------------------------------------------------------------------
/src/rootEndpoints.json:
--------------------------------------------------------------------------------
1 | [
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/"]
51 | ]
--------------------------------------------------------------------------------
/src/endpoints.json:
--------------------------------------------------------------------------------
1 | [
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/"]
51 | ]
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import localForage from "localforage"
2 |
3 | import endpoints from './endpoints.json'
4 | import rootEndpoints from './rootEndpoints.json'
5 | import { loadResource } from './getter.js'
6 | import { installSW } from './installSW.js'
7 | import { Config } from './config.js'
8 |
9 | localForage.config({
10 | name: 'pokeapi-js-wrapper'
11 | })
12 |
13 | export class Pokedex {
14 |
15 | constructor(config) {
16 | this.config = new Config(config)
17 |
18 | // add to Pokedex.prototype all our endpoint functions
19 | endpoints.forEach(endpoint => {
20 | const endpointFullName = buildEndpointFullName(endpoint)
21 | this[endpointFullName] = input => {
22 | if (input) {
23 |
24 | // if the user has submitted a Name or an ID, return the JSON promise
25 | if (typeof input === 'number' || typeof input === 'string') {
26 | return loadResource(this.config, `${this.config.versionPath}${endpoint[2].replace(':id', input)}`)
27 | }
28 |
29 | // if the user has submitted an Array
30 | // return a new promise which will resolve when all loadResource calls are ended
31 | else if (typeof input === 'object') {
32 | return Promise.all(mapResources(this.config, endpoint, input))
33 | }
34 | }
35 | }
36 | this[buildEndpointName(endpoint)] = this[endpointFullName]
37 | })
38 |
39 | rootEndpoints.forEach(rootEndpoint => {
40 | const rootEndpointFullName = buildRootEndpointFullName(rootEndpoint)
41 | this[rootEndpointFullName] = config => {
42 | var limit = this.config.limit
43 | var offset = this.config.offset
44 | if (config) {
45 | if (config.hasOwnProperty('offset')) {
46 | offset = config.offset
47 | }
48 | if (config.hasOwnProperty('limit')) {
49 | limit = config.limit
50 | }
51 | }
52 | return loadResource(this.config, `${this.config.versionPath}${rootEndpoint[1]}?limit=${limit}&offset=${offset}`)
53 | }
54 | this[rootEndpoint[0]] = this[rootEndpointFullName]
55 | })
56 |
57 | if (this.config.cacheImages) {
58 | installSW()
59 | }
60 | }
61 |
62 | getConfig() {
63 | return this.config
64 | }
65 |
66 | getCacheLength() {
67 | return localForage.length()
68 | }
69 |
70 | clearCache() {
71 | return localForage.clear()
72 | }
73 |
74 | resource(path) {
75 | if (typeof path === 'string') {
76 | return loadResource(this.config, path)
77 | } else if (Array.isArray(path)) {
78 | return Promise.all(path.map(p => loadResource(this.config, p)))
79 | } else {
80 | return 'String or Array is required'
81 | }
82 | }
83 | }
84 |
85 | function mapResources(config, endpoint, inputs) {
86 | return inputs.map(input => {
87 | return loadResource(config, `${config.versionPath}${endpoint[2].replace(':id', input)}`)
88 | })
89 | }
90 |
91 | function buildEndpointFullName(endpoint) {
92 | return `${endpoint[0]}By${capitalize(endpoint[1])}`
93 | }
94 |
95 | function buildEndpointName(endpoint) {
96 | return `${endpoint[0]}`
97 | }
98 |
99 | function buildRootEndpointFullName(endpoint) {
100 | return `${endpoint[0]}List`
101 | }
102 |
103 | function capitalize([first,...rest]) {
104 | return first.toUpperCase() + rest.join('').toLowerCase()
105 | }
106 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Mozilla Public License Version 2.0
2 | ==================================
3 |
4 | 1. Definitions
5 | --------------
6 |
7 | 1.1. "Contributor"
8 | means each individual or legal entity that creates, contributes to
9 | the creation of, or owns Covered Software.
10 |
11 | 1.2. "Contributor Version"
12 | means the combination of the Contributions of others (if any) used
13 | by a Contributor and that particular Contributor's Contribution.
14 |
15 | 1.3. "Contribution"
16 | means Covered Software of a particular Contributor.
17 |
18 | 1.4. "Covered Software"
19 | means Source Code Form to which the initial Contributor has attached
20 | the notice in Exhibit A, the Executable Form of such Source Code
21 | Form, and Modifications of such Source Code Form, in each case
22 | including portions thereof.
23 |
24 | 1.5. "Incompatible With Secondary Licenses"
25 | means
26 |
27 | (a) that the initial Contributor has attached the notice described
28 | in Exhibit B to the Covered Software; or
29 |
30 | (b) that the Covered Software was made available under the terms of
31 | version 1.1 or earlier of the License, but not also under the
32 | terms of a Secondary License.
33 |
34 | 1.6. "Executable Form"
35 | means any form of the work other than Source Code Form.
36 |
37 | 1.7. "Larger Work"
38 | means a work that combines Covered Software with other material, in
39 | a separate file or files, that is not Covered Software.
40 |
41 | 1.8. "License"
42 | means this document.
43 |
44 | 1.9. "Licensable"
45 | means having the right to grant, to the maximum extent possible,
46 | whether at the time of the initial grant or subsequently, any and
47 | all of the rights conveyed by this License.
48 |
49 | 1.10. "Modifications"
50 | means any of the following:
51 |
52 | (a) any file in Source Code Form that results from an addition to,
53 | deletion from, or modification of the contents of Covered
54 | Software; or
55 |
56 | (b) any new file in Source Code Form that contains any Covered
57 | Software.
58 |
59 | 1.11. "Patent Claims" of a Contributor
60 | means any patent claim(s), including without limitation, method,
61 | process, and apparatus claims, in any patent Licensable by such
62 | Contributor that would be infringed, but for the grant of the
63 | License, by the making, using, selling, offering for sale, having
64 | made, import, or transfer of either its Contributions or its
65 | Contributor Version.
66 |
67 | 1.12. "Secondary License"
68 | means either the GNU General Public License, Version 2.0, the GNU
69 | Lesser General Public License, Version 2.1, the GNU Affero General
70 | Public License, Version 3.0, or any later versions of those
71 | licenses.
72 |
73 | 1.13. "Source Code Form"
74 | means the form of the work preferred for making modifications.
75 |
76 | 1.14. "You" (or "Your")
77 | means an individual or a legal entity exercising rights under this
78 | License. For legal entities, "You" includes any entity that
79 | controls, is controlled by, or is under common control with You. For
80 | purposes of this definition, "control" means (a) the power, direct
81 | or indirect, to cause the direction or management of such entity,
82 | whether by contract or otherwise, or (b) ownership of more than
83 | fifty percent (50%) of the outstanding shares or beneficial
84 | ownership of such entity.
85 |
86 | 2. License Grants and Conditions
87 | --------------------------------
88 |
89 | 2.1. Grants
90 |
91 | Each Contributor hereby grants You a world-wide, royalty-free,
92 | non-exclusive license:
93 |
94 | (a) under intellectual property rights (other than patent or trademark)
95 | Licensable by such Contributor to use, reproduce, make available,
96 | modify, display, perform, distribute, and otherwise exploit its
97 | Contributions, either on an unmodified basis, with Modifications, or
98 | as part of a Larger Work; and
99 |
100 | (b) under Patent Claims of such Contributor to make, use, sell, offer
101 | for sale, have made, import, and otherwise transfer either its
102 | Contributions or its Contributor Version.
103 |
104 | 2.2. Effective Date
105 |
106 | The licenses granted in Section 2.1 with respect to any Contribution
107 | become effective for each Contribution on the date the Contributor first
108 | distributes such Contribution.
109 |
110 | 2.3. Limitations on Grant Scope
111 |
112 | The licenses granted in this Section 2 are the only rights granted under
113 | this License. No additional rights or licenses will be implied from the
114 | distribution or licensing of Covered Software under this License.
115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
116 | Contributor:
117 |
118 | (a) for any code that a Contributor has removed from Covered Software;
119 | or
120 |
121 | (b) for infringements caused by: (i) Your and any other third party's
122 | modifications of Covered Software, or (ii) the combination of its
123 | Contributions with other software (except as part of its Contributor
124 | Version); or
125 |
126 | (c) under Patent Claims infringed by Covered Software in the absence of
127 | its Contributions.
128 |
129 | This License does not grant any rights in the trademarks, service marks,
130 | or logos of any Contributor (except as may be necessary to comply with
131 | the notice requirements in Section 3.4).
132 |
133 | 2.4. Subsequent Licenses
134 |
135 | No Contributor makes additional grants as a result of Your choice to
136 | distribute the Covered Software under a subsequent version of this
137 | License (see Section 10.2) or under the terms of a Secondary License (if
138 | permitted under the terms of Section 3.3).
139 |
140 | 2.5. Representation
141 |
142 | Each Contributor represents that the Contributor believes its
143 | Contributions are its original creation(s) or it has sufficient rights
144 | to grant the rights to its Contributions conveyed by this License.
145 |
146 | 2.6. Fair Use
147 |
148 | This License is not intended to limit any rights You have under
149 | applicable copyright doctrines of fair use, fair dealing, or other
150 | equivalents.
151 |
152 | 2.7. Conditions
153 |
154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155 | in Section 2.1.
156 |
157 | 3. Responsibilities
158 | -------------------
159 |
160 | 3.1. Distribution of Source Form
161 |
162 | All distribution of Covered Software in Source Code Form, including any
163 | Modifications that You create or to which You contribute, must be under
164 | the terms of this License. You must inform recipients that the Source
165 | Code Form of the Covered Software is governed by the terms of this
166 | License, and how they can obtain a copy of this License. You may not
167 | attempt to alter or restrict the recipients' rights in the Source Code
168 | Form.
169 |
170 | 3.2. Distribution of Executable Form
171 |
172 | If You distribute Covered Software in Executable Form then:
173 |
174 | (a) such Covered Software must also be made available in Source Code
175 | Form, as described in Section 3.1, and You must inform recipients of
176 | the Executable Form how they can obtain a copy of such Source Code
177 | Form by reasonable means in a timely manner, at a charge no more
178 | than the cost of distribution to the recipient; and
179 |
180 | (b) You may distribute such Executable Form under the terms of this
181 | License, or sublicense it under different terms, provided that the
182 | license for the Executable Form does not attempt to limit or alter
183 | the recipients' rights in the Source Code Form under this License.
184 |
185 | 3.3. Distribution of a Larger Work
186 |
187 | You may create and distribute a Larger Work under terms of Your choice,
188 | provided that You also comply with the requirements of this License for
189 | the Covered Software. If the Larger Work is a combination of Covered
190 | Software with a work governed by one or more Secondary Licenses, and the
191 | Covered Software is not Incompatible With Secondary Licenses, this
192 | License permits You to additionally distribute such Covered Software
193 | under the terms of such Secondary License(s), so that the recipient of
194 | the Larger Work may, at their option, further distribute the Covered
195 | Software under the terms of either this License or such Secondary
196 | License(s).
197 |
198 | 3.4. Notices
199 |
200 | You may not remove or alter the substance of any license notices
201 | (including copyright notices, patent notices, disclaimers of warranty,
202 | or limitations of liability) contained within the Source Code Form of
203 | the Covered Software, except that You may alter any license notices to
204 | the extent required to remedy known factual inaccuracies.
205 |
206 | 3.5. Application of Additional Terms
207 |
208 | You may choose to offer, and to charge a fee for, warranty, support,
209 | indemnity or liability obligations to one or more recipients of Covered
210 | Software. However, You may do so only on Your own behalf, and not on
211 | behalf of any Contributor. You must make it absolutely clear that any
212 | such warranty, support, indemnity, or liability obligation is offered by
213 | You alone, and You hereby agree to indemnify every Contributor for any
214 | liability incurred by such Contributor as a result of warranty, support,
215 | indemnity or liability terms You offer. You may include additional
216 | disclaimers of warranty and limitations of liability specific to any
217 | jurisdiction.
218 |
219 | 4. Inability to Comply Due to Statute or Regulation
220 | ---------------------------------------------------
221 |
222 | If it is impossible for You to comply with any of the terms of this
223 | License with respect to some or all of the Covered Software due to
224 | statute, judicial order, or regulation then You must: (a) comply with
225 | the terms of this License to the maximum extent possible; and (b)
226 | describe the limitations and the code they affect. Such description must
227 | be placed in a text file included with all distributions of the Covered
228 | Software under this License. Except to the extent prohibited by statute
229 | or regulation, such description must be sufficiently detailed for a
230 | recipient of ordinary skill to be able to understand it.
231 |
232 | 5. Termination
233 | --------------
234 |
235 | 5.1. The rights granted under this License will terminate automatically
236 | if You fail to comply with any of its terms. However, if You become
237 | compliant, then the rights granted under this License from a particular
238 | Contributor are reinstated (a) provisionally, unless and until such
239 | Contributor explicitly and finally terminates Your grants, and (b) on an
240 | ongoing basis, if such Contributor fails to notify You of the
241 | non-compliance by some reasonable means prior to 60 days after You have
242 | come back into compliance. Moreover, Your grants from a particular
243 | Contributor are reinstated on an ongoing basis if such Contributor
244 | notifies You of the non-compliance by some reasonable means, this is the
245 | first time You have received notice of non-compliance with this License
246 | from such Contributor, and You become compliant prior to 30 days after
247 | Your receipt of the notice.
248 |
249 | 5.2. If You initiate litigation against any entity by asserting a patent
250 | infringement claim (excluding declaratory judgment actions,
251 | counter-claims, and cross-claims) alleging that a Contributor Version
252 | directly or indirectly infringes any patent, then the rights granted to
253 | You by any and all Contributors for the Covered Software under Section
254 | 2.1 of this License shall terminate.
255 |
256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257 | end user license agreements (excluding distributors and resellers) which
258 | have been validly granted by You or Your distributors under this License
259 | prior to termination shall survive termination.
260 |
261 | ************************************************************************
262 | * *
263 | * 6. Disclaimer of Warranty *
264 | * ------------------------- *
265 | * *
266 | * Covered Software is provided under this License on an "as is" *
267 | * basis, without warranty of any kind, either expressed, implied, or *
268 | * statutory, including, without limitation, warranties that the *
269 | * Covered Software is free of defects, merchantable, fit for a *
270 | * particular purpose or non-infringing. The entire risk as to the *
271 | * quality and performance of the Covered Software is with You. *
272 | * Should any Covered Software prove defective in any respect, You *
273 | * (not any Contributor) assume the cost of any necessary servicing, *
274 | * repair, or correction. This disclaimer of warranty constitutes an *
275 | * essential part of this License. No use of any Covered Software is *
276 | * authorized under this License except under this disclaimer. *
277 | * *
278 | ************************************************************************
279 |
280 | ************************************************************************
281 | * *
282 | * 7. Limitation of Liability *
283 | * -------------------------- *
284 | * *
285 | * Under no circumstances and under no legal theory, whether tort *
286 | * (including negligence), contract, or otherwise, shall any *
287 | * Contributor, or anyone who distributes Covered Software as *
288 | * permitted above, be liable to You for any direct, indirect, *
289 | * special, incidental, or consequential damages of any character *
290 | * including, without limitation, damages for lost profits, loss of *
291 | * goodwill, work stoppage, computer failure or malfunction, or any *
292 | * and all other commercial damages or losses, even if such party *
293 | * shall have been informed of the possibility of such damages. This *
294 | * limitation of liability shall not apply to liability for death or *
295 | * personal injury resulting from such party's negligence to the *
296 | * extent applicable law prohibits such limitation. Some *
297 | * jurisdictions do not allow the exclusion or limitation of *
298 | * incidental or consequential damages, so this exclusion and *
299 | * limitation may not apply to You. *
300 | * *
301 | ************************************************************************
302 |
303 | 8. Litigation
304 | -------------
305 |
306 | Any litigation relating to this License may be brought only in the
307 | courts of a jurisdiction where the defendant maintains its principal
308 | place of business and such litigation shall be governed by laws of that
309 | jurisdiction, without reference to its conflict-of-law provisions.
310 | Nothing in this Section shall prevent a party's ability to bring
311 | cross-claims or counter-claims.
312 |
313 | 9. Miscellaneous
314 | ----------------
315 |
316 | This License represents the complete agreement concerning the subject
317 | matter hereof. If any provision of this License is held to be
318 | unenforceable, such provision shall be reformed only to the extent
319 | necessary to make it enforceable. Any law or regulation which provides
320 | that the language of a contract shall be construed against the drafter
321 | shall not be used to construe this License against a Contributor.
322 |
323 | 10. Versions of the License
324 | ---------------------------
325 |
326 | 10.1. New Versions
327 |
328 | Mozilla Foundation is the license steward. Except as provided in Section
329 | 10.3, no one other than the license steward has the right to modify or
330 | publish new versions of this License. Each version will be given a
331 | distinguishing version number.
332 |
333 | 10.2. Effect of New Versions
334 |
335 | You may distribute the Covered Software under the terms of the version
336 | of the License under which You originally received the Covered Software,
337 | or under the terms of any subsequent version published by the license
338 | steward.
339 |
340 | 10.3. Modified Versions
341 |
342 | If you create software not governed by this License, and you want to
343 | create a new license for such software, you may create and use a
344 | modified version of this License if you rename the license and remove
345 | any references to the name of the license steward (except to note that
346 | such modified license differs from this License).
347 |
348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
349 | Licenses
350 |
351 | If You choose to distribute Source Code Form that is Incompatible With
352 | Secondary Licenses under the terms of this version of the License, the
353 | notice described in Exhibit B of this License must be attached.
354 |
355 | Exhibit A - Source Code Form License Notice
356 | -------------------------------------------
357 |
358 | This Source Code Form is subject to the terms of the Mozilla Public
359 | License, v. 2.0. If a copy of the MPL was not distributed with this
360 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
361 |
362 | If it is not possible or desirable to put the notice in a particular
363 | file, then You may include the notice in a location (such as a LICENSE
364 | file in a relevant directory) where a recipient would be likely to look
365 | for such a notice.
366 |
367 | You may add additional accurate notices of copyright ownership.
368 |
369 | Exhibit B - "Incompatible With Secondary Licenses" Notice
370 | ---------------------------------------------------------
371 |
372 | This Source Code Form is "Incompatible With Secondary Licenses", as
373 | defined by the Mozilla Public License, v. 2.0.
374 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # pokeapi-js-wrapper
2 |
3 | [](https://www.npmjs.com/package/pokeapi-js-wrapper)
4 | [](https://github.com/PokeAPI/pokeapi-js-wrapper/actions/workflows/test.yml)
5 | [](https://pokeapi.github.io/pokeapi-js-wrapper/test/test.html)
6 | [](https://codecov.io/gh/PokeAPI/pokeapi-js-wrapper)
7 |
8 | Maintainer: [Naramsim](https://github.com/Naramsim)
9 |
10 | A PokeAPI wrapper intended for browsers only. Comes fully asynchronous (with [localForage](https://github.com/localForage/localForage)) and built-in cache. Offers also Image Caching through the inclusion of a Service Worker. _For a Node (server-side) wrapper see: [pokedex-promise-v2](https://github.com/PokeAPI/pokedex-promise-v2)_
11 |
12 |
13 |
14 |
15 | - [Install](#install)
16 | - [Usage](#usage)
17 | - [Example requests](#example-requests)
18 | - [Configuration](#configuration)
19 | - [Caching images](#caching-images)
20 | - [Tests](#tests)
21 | - [Endpoints](#endpoints)
22 | - [Root Endpoints list](#root-endpoints-list)
23 | - [Custom URLs and paths](#custom-urls-and-paths)
24 | - [Internet Explorer 8](#internet-explorer-8)
25 |
26 |
27 |
28 | ## Install
29 |
30 | ```sh
31 | npm install pokeapi-js-wrapper --save
32 | ```
33 |
34 | ```html
35 |
36 | ```
37 |
38 | ## Usage
39 |
40 | ```js
41 | const Pokedex = require("pokeapi-js-wrapper")
42 | const P = new Pokedex.Pokedex()
43 | ```
44 |
45 | ```html
46 |
49 | ```
50 |
51 | ### [Example](https://jsbin.com/jedakor/5/edit?html,console) requests
52 |
53 | ```js
54 | // with await, be sure to be in an async function (and in a try/catch)
55 | (async () => {
56 | const golduck = await P.getPokemonByName("golduck")
57 | console.log(golduck)
58 | })()
59 |
60 | // or with Promises
61 | P.getPokemonByName("eevee")
62 | .then(function(response) {
63 | console.log(response)
64 | })
65 |
66 | P.resource([
67 | "/api/v2/pokemon/36",
68 | "api/v2/berry/8",
69 | "https://pokeapi.co/api/v2/ability/9/",
70 | ]).then( response => {
71 | console.log(response)
72 | })
73 | ```
74 |
75 | ## Configuration
76 |
77 | Pass an Object to `Pokedex()` in order to configure it. Available options: `protocol`, `hostName`, `versionPath`, `cache`, `timeout`(ms), and `cacheImages`.
78 | Any option is optional :smile:. All the default values can be found [here](https://github.com/PokeAPI/pokeapi-js-wrapper/blob/master/src/config.js#L3-L10)
79 |
80 | ```js
81 | const Pokedex = require("pokeapi-js-wrapper")
82 | const customOptions = {
83 | protocol: "https",
84 | hostName: "localhost:443",
85 | versionPath: "/api/v2/",
86 | cache: true,
87 | timeout: 5 * 1000, // 5s
88 | cacheImages: true
89 | }
90 | const P = new Pokedex.Pokedex(customOptions)
91 | ```
92 |
93 | ### Caching images
94 |
95 | Pokeapi.co serves its Pokemon images through [Github](https://github.com/PokeAPI/sprites). For example, the front default DreamWorld image of Pikachu is found at this URL: `https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/dream-world/25.svg`.
96 |
97 | `pokeapi-js-wrapper` enables browsers to cache all these images by:
98 |
99 | 1. enabling the config parameter `cacheImages`
100 | 2. serving [our service worker](https://raw.githubusercontent.com/PokeAPI/pokeapi-js-wrapper/master/dist/pokeapi-js-wrapper-sw.js) from the root of your project
101 |
102 | In this way when `pokeapi-js-wrapper`'s `Pokedex` is created it will install and start the Service Worker you are serving at the root of your server. The Service Worker will intercept all the calls your HTML/CSS/JS are making to get PokeAPI's images and will cache them.
103 |
104 | It's fundamental that you download the Service Worker [we provide](https://raw.githubusercontent.com/PokeAPI/pokeapi-js-wrapper/master/dist/pokeapi-js-wrapper-sw.js)_(Right Click + Save As)_ and you serve it from the root of your project/server. Service Workers in fact cannot be installed from a domain different than yours.
105 |
106 | A [basic example](https://github.com/PokeAPI/pokeapi-js-wrapper/blob/master/test/example-sw.html) is hosted [here](https://pokeapi.github.io/pokeapi-js-wrapper/test/example-sw.html).
107 |
108 | ## Tests
109 |
110 | `pokeapi-js-wrapper` can be tested using two strategies. One is with Node, since this package works with Node (although not recommended), and the other with a browser.
111 |
112 | ```js
113 | npm test
114 | ```
115 |
116 | Or open `/test/test.html` in your browser. A live version can be found at [`gh-pages`](https://pokeapi.github.io/pokeapi-js-wrapper/test/test.html)
117 |
118 | ## Endpoints
119 |
120 | All the endpoints and the functions to access PokeAPI's endpoints are listed in the long table below. Each function `.ByName(name)` accepts names and ids. The only 5 functions `.ById(id)` only accept ids. You can also pass an array to each function, it will retrieve the data for each element asynchronously.
121 |
122 | ```js
123 | P.getPokemonByName("eevee").then(function(response) {
124 | console.log(response)
125 | })
126 |
127 | P.getPokemonSpeciesByName(25).then(function(response) {
128 | console.log(response)
129 | })
130 |
131 | P.getBerryByName(["cheri", "chesto", 5]).then(function(response) {
132 | // `response` will be an Array containing 3 Objects
133 | // response.forEach((item) => {console.log(item.size)}) // 80,50,20
134 | console.log(response)
135 | })
136 |
137 | P.getMachineById(3).then(function(response) {
138 | console.log(response)
139 | })
140 | ```
141 |
142 | | Function | Mapped PokeAPI endpoint | Documentation |
143 | | --- | --- | --- |
144 | | `getBerryByName(name)` | [/berry/:name](https://pokeapi.co/api/v2/berry/:name/) | [Documentation](https://pokeapi.co/docs/v2#berries) |
145 | | `getBerryFirmnessByName(name)` | [/berry-firmness/:name](https://pokeapi.co/api/v2/berry-firmness/:name/) | [Documentation](https://pokeapi.co/docs/v2#berry-firmnesses) |
146 | | `getBerryFlavorByName(name)` | [/berry-flavor/:name](https://pokeapi.co/api/v2/berry-flavor/:name/) | [Documentation](https://pokeapi.co/docs/v2#berry-flavors) |
147 | | `getContestTypeByName(name)` | [/contest-type/:name](https://pokeapi.co/api/v2/contest-type/:name/) | [Documentation](https://pokeapi.co/docs/v2#contest-types) |
148 | | `getContestEffectById(id)` | [/contest-effect/:id](https://pokeapi.co/api/v2/contest-effect/:id/) | [Documentation](https://pokeapi.co/docs/v2#contest-effects) |
149 | | `getSuperContestEffectById(id)` | [/super-contest-effect/:id](https://pokeapi.co/api/v2/super-contest-effect/:id/) | [Documentation](https://pokeapi.co/docs/v2#super-contest-effects) |
150 | | `getEncounterMethodByName(name)` | [/encounter-method/:name](https://pokeapi.co/api/v2/encounter-method/:name/) | [Documentation](https://pokeapi.co/docs/v2#encounter-methods) |
151 | | `getEncounterConditionByName(name)` | [/encounter-condition/:name](https://pokeapi.co/api/v2/encounter-condition/:name/) | [Documentation](https://pokeapi.co/docs/v2#encounter-conditions) |
152 | | `getEncounterConditionValueByName(name)` | [/encounter-condition-value/:nam/](https://pokeapi.co/api/v2/encounter-condition-value/:name/) | [Documentation](https://pokeapi.co/docs/v2#encounter-condition-values) |
153 | | `getEvolutionChainById(id)` | [/evolution-chain/:id](https://pokeapi.co/api/v2/evolution-chain/:id/) | [Documentation](https://pokeapi.co/docs/v2#evolution-chains) |
154 | | `getEvolutionTriggerByName(name)` | [/evolution-trigger/:name](https://pokeapi.co/api/v2/evolution-trigger/:name/) | [Documentation](https://pokeapi.co/docs/v2#evolution-triggers) |
155 | | `getGenerationByName(name)` | [/generation/:name](https://pokeapi.co/api/v2/generation/:name/) | [Documentation](https://pokeapi.co/docs/v2#generations) |
156 | | `getPokedexByName(name)` | [/pokedex/:name](https://pokeapi.co/api/v2/pokedex/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokedexes) |
157 | | `getVersionByName(name)` | [/version/:name](https://pokeapi.co/api/v2/version/:name/) | [Documentation](https://pokeapi.co/docs/v2#version) |
158 | | `getVersionGroupByName(name)` | [/version-group/:name](https://pokeapi.co/api/v2/version-group/:name/) | [Documentation](https://pokeapi.co/docs/v2#version-groups) |
159 | | `getItemByName(name)` | [/item/:name](https://pokeapi.co/api/v2/item/:name/) | [Documentation](https://pokeapi.co/docs/v2#item) |
160 | | `getItemAttributeByName(name)` | [/item-attribute/:name](https://pokeapi.co/api/v2/item-attribute/:name/) | [Documentation](https://pokeapi.co/docs/v2#item-attributes) |
161 | | `getItemCategoryByName(name)` | [/item-category/:name](https://pokeapi.co/api/v2/item-category/:name/) | [Documentation](https://pokeapi.co/docs/v2#item-categories) |
162 | | `getItemFlingEffectByName(name)` | [/item-fling-effect/:name](https://pokeapi.co/api/v2/item-fling-effect/:name/) | [Documentation](https://pokeapi.co/docs/v2#item-fling-effects) |
163 | | `getItemPocketByName(name)` | [/item-pocket/:name](https://pokeapi.co/api/v2/item-pocket/:name/) | [Documentation](https://pokeapi.co/docs/v2#item-pockets) |
164 | | `getMachineById(id)` | [/machine/:id](https://pokeapi.co/api/v2/machine/:id/) | [Documentation](https://pokeapi.co/docs/v2#machines) |
165 | | `getMoveByName(name)` | [/move/:name](https://pokeapi.co/api/v2/move/:name/) | [Documentation](https://pokeapi.co/docs/v2#moves) |
166 | | `getMoveAilmentByName(name)` | [/move-ailment/:name](https://pokeapi.co/api/v2/move-ailment/:name/) | [Documentation](https://pokeapi.co/docs/v2#move-ailments) |
167 | | `getMoveBattleStyleByName(name)` | [/move-battle-style/:name](https://pokeapi.co/api/v2/move-battle-style/:name/) | [Documentation](https://pokeapi.co/docs/v2#move-battle-styles) |
168 | | `getMoveCategoryByName(name)` | [/move-category/:name](https://pokeapi.co/api/v2/move-category/:name/) | [Documentation](https://pokeapi.co/docs/v2#move-categories) |
169 | | `getMoveDamageClassByName(name)` | [/move-damage-class/:name](https://pokeapi.co/api/v2/move-damage-class/:name/) | [Documentation](https://pokeapi.co/docs/v2#move-damage-classes) |
170 | | `getMoveLearnMethodByName(name)` | [/move-learn-method/:name](https://pokeapi.co/api/v2/move-learn-method/:name/) | [Documentation](https://pokeapi.co/docs/v2#move-learn-methods) |
171 | | `getMoveTargetByName(name)` | [/move-target/:name](https://pokeapi.co/api/v2/move-target/:name/) | [Documentation](https://pokeapi.co/docs/v2#move-targets) |
172 | | `getLocationByName(name)` | [/location/:name](https://pokeapi.co/api/v2/location/:name/) | [Documentation](https://pokeapi.co/docs/v2#locations) |
173 | | `getLocationAreaByName(name)` | [/location-area/:name](https://pokeapi.co/api/v2/location-area/:name/) | [Documentation](https://pokeapi.co/docs/v2#location-areas) |
174 | | `getPalParkAreaByName(name)` | [/pal-park-area/:name](https://pokeapi.co/api/v2/pal-park-area/:name/) | [Documentation](https://pokeapi.co/docs/v2#pal-park-areas) |
175 | | `getRegionByName(name)` | [/region/:name](https://pokeapi.co/api/v2/region/:name/) | [Documentation](https://pokeapi.co/docs/v2#regions) |
176 | | `getAbilityByName(name)` | [/ability/:name](https://pokeapi.co/api/v2/ability/:name/) | [Documentation](https://pokeapi.co/docs/v2#abilities) |
177 | | `getCharacteristicById(id)` | [/characteristic/:id](https://pokeapi.co/api/v2/characteristic/:id/) | [Documentation](https://pokeapi.co/docs/v2#characteristics) |
178 | | `getEggGroupByName(name)` | [/egg-group/:name](https://pokeapi.co/api/v2/egg-group/:name/) | [Documentation](https://pokeapi.co/docs/v2#egg-groups) |
179 | | `getGenderByName(name)` | [/gender/:name](https://pokeapi.co/api/v2/gender/:name/) | [Documentation](https://pokeapi.co/docs/v2#genders) |
180 | | `getGrowthRateByName(name)` | [/growth-rate/:name](https://pokeapi.co/api/v2/growth-rate/:name/) | [Documentation](https://pokeapi.co/docs/v2#growth-rates) |
181 | | `getNatureByName(name)` | [/nature/:name](https://pokeapi.co/api/v2/nature/:name/) | [Documentation](https://pokeapi.co/docs/v2#natures) |
182 | | `getPokeathlonStatByName(name)` | [/pokeathlon-stat/:name](https://pokeapi.co/api/v2/pokeathlon-stat/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokeathlon-stats) |
183 | | `getPokemonByName(name)` | [/pokemon/:name](https://pokeapi.co/api/v2/pokemon/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokemon) |
184 | | `getPokemonEncounterAreasByName(name)` | [/pokemon/:name/encounters](https://pokeapi.co/api/v2/pokemon/:name/encounters/) | [Documentation](https://pokeapi.co/docs/v2#pokemon-location-areas) |
185 | | `getPokemonColorByName(name)` | [/pokemon-color/:name](https://pokeapi.co/api/v2/pokemon-color/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokemon-colors) |
186 | | `getPokemonFormByName(name)` | [/pokemon-form/:name](https://pokeapi.co/api/v2/pokemon-form/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokemon-forms) |
187 | | `getPokemonHabitatByName(name)` | [/pokemon-habitat/:name](https://pokeapi.co/api/v2/pokemon-habitat/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokemon-habitats) |
188 | | `getPokemonShapeByName(name)` | [/pokemon-shape/:name](https://pokeapi.co/api/v2/pokemon-shape/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokemon-shapes) |
189 | | `getPokemonSpeciesByName(name)` | [/pokemon-species/:name](https://pokeapi.co/api/v2/pokemon-species/:name/) | [Documentation](https://pokeapi.co/docs/v2#pokemon-species) |
190 | | `getStatByName(name)` | [/stat/:name](https://pokeapi.co/api/v2/stat/:name/) | [Documentation](https://pokeapi.co/docs/v2#stats) |
191 | | `getTypeByName(name)` | [/type/:name](https://pokeapi.co/api/v2/type/:name/) | [Documentation](https://pokeapi.co/docs/v2#types) |
192 | | `getLanguageByName(name)` | [/language/:name](https://pokeapi.co/api/v2/language/:name/) | [Documentation](https://pokeapi.co/docs/v2#languages) |
193 |
194 | ### Root Endpoints list
195 |
196 | For each PokeAPI's root endpoint we provide a method to get all the items served by that endpoint. By default the method will return every item in the endpoint. If needed an offset and a limit can be configured.
197 |
198 | - `offset` is where to start. The first item that you will get. Default `0`
199 | - `limit` is how many items you want to list. Default `100000`
200 |
201 | > **TIP**: Do not pass any config Object to your call, since you will get every item and everything will be cached
202 |
203 | The following snippet will get the list of Pokémon between ID 34 and ID 44
204 |
205 | ```js
206 | const interval = {
207 | offset: 34,
208 | limit: 10,
209 | }
210 | P.getPokemonsList(interval).then(function(response) {
211 | console.log(response)
212 | })
213 | ```
214 |
215 |
245 |
246 | | Function | Mapped PokeAPI endpoint |
247 | | --- | --- |
248 | | `getEndpointsList()` | [/](https://pokeapi.co/api/v2/) |
249 | | `getBerriesList()` | [/berry](https://pokeapi.co/api/v2/berry/) |
250 | | `getBerriesFirmnesssList()` | [/berry-firmness](https://pokeapi.co/api/v2/berry-firmness/) |
251 | | `getBerriesFlavorsList()` | [/berry-flavor](https://pokeapi.co/api/v2/berry-flavor/) |
252 | | `getContestTypesList()` | [/contest-type](https://pokeapi.co/api/v2/contest-type/) |
253 | | `getContestEffectsList()` | [/contest-effect](https://pokeapi.co/api/v2/contest-effect/) |
254 | | `getSuperContestEffectsList()` | [/super-contest-effect](https://pokeapi.co/api/v2/super-contest-effect/) |
255 | | `getEncounterMethodsList()` | [/encounter-method](https://pokeapi.co/api/v2/encounter-method/) |
256 | | `getEncounterConditionsList()` | [/encounter-condition](https://pokeapi.co/api/v2/encounter-condition/) |
257 | | `getEncounterConditionValuesList()` | [/encounter-condition-value](https://pokeapi.co/api/v2/encounter-condition-value/) |
258 | | `getEvolutionChainsList()` | [/evolution-chain](https://pokeapi.co/api/v2/evolution-chain/) |
259 | | `getEvolutionTriggersList()` | [/evolution-trigger](https://pokeapi.co/api/v2/evolution-trigger/) |
260 | | `getGenerationsList()` | [/generation](https://pokeapi.co/api/v2/generation/) |
261 | | `getPokedexsList()` | [/pokedex](https://pokeapi.co/api/v2/pokedex/) |
262 | | `getVersionsList()` | [/version](https://pokeapi.co/api/v2/version/) |
263 | | `getVersionGroupsList()` | [/version-group](https://pokeapi.co/api/v2/version-group/) |
264 | | `getItemsList()` | [/item](https://pokeapi.co/api/v2/item/) |
265 | | `getItemAttributesList()` | [/item-attribute](https://pokeapi.co/api/v2/item-attribute/) |
266 | | `getItemCategoriesList()` | [/item-category](https://pokeapi.co/api/v2/item-category/) |
267 | | `getItemFlingEffectsList()` | [/item-fling-effect](https://pokeapi.co/api/v2/item-fling-effect/) |
268 | | `getItemPocketsList()` | [/item-pocket](https://pokeapi.co/api/v2/item-pocket/) |
269 | | `getMachinesList()` | [/machine](https://pokeapi.co/api/v2/machine/) |
270 | | `getMovesList()` | [/move](https://pokeapi.co/api/v2/move/) |
271 | | `getMoveAilmentsList()` | [/move-ailment](https://pokeapi.co/api/v2/move-ailment/) |
272 | | `getMoveBattleStylesList()` | [/move-battle-style](https://pokeapi.co/api/v2/move-battle-style/) |
273 | | `getMoveCategoriesList()` | [/move-category](https://pokeapi.co/api/v2/move-category/) |
274 | | `getMoveDamageClassesList()` | [/move-damage-class](https://pokeapi.co/api/v2/move-damage-class/) |
275 | | `getMoveLearnMethodsList()` | [/move-learn-method](https://pokeapi.co/api/v2/move-learn-method/) |
276 | | `getMoveTargetsList()` | [/move-target](https://pokeapi.co/api/v2/move-target/) |
277 | | `getLocationsList()` | [/location](https://pokeapi.co/api/v2/location/) |
278 | | `getLocationAreasList()` | [/location-area](https://pokeapi.co/api/v2/location-area/) |
279 | | `getPalParkAreasList()` | [/pal-park-area](https://pokeapi.co/api/v2/pal-park-area/) |
280 | | `getRegionsList()` | [/region](https://pokeapi.co/api/v2/region/) |
281 | | `getAbilitiesList()` | [/ability](https://pokeapi.co/api/v2/ability/) |
282 | | `getCharacteristicsList()` | [/characteristic](https://pokeapi.co/api/v2/characteristic/) |
283 | | `getEggGroupsList()` | [/egg-group](https://pokeapi.co/api/v2/egg-group/) |
284 | | `getGendersList()` | [/gender](https://pokeapi.co/api/v2/gender/) |
285 | | `getGrowthRatesList()` | [/growth-rate](https://pokeapi.co/api/v2/growth-rate/) |
286 | | `getNaturesList()` | [/nature](https://pokeapi.co/api/v2/nature/) |
287 | | `getPokeathlonStatsList()` | [/pokeathlon-stat](https://pokeapi.co/api/v2/pokeathlon-stat/) |
288 | | `getPokemonsList()` | [/pokemon](https://pokeapi.co/api/v2/pokemon/) |
289 | | `getPokemonColorsList()` | [/pokemon-color](https://pokeapi.co/api/v2/pokemon-color/) |
290 | | `getPokemonFormsList()` | [/pokemon-form](https://pokeapi.co/api/v2/pokemon-form/) |
291 | | `getPokemonHabitatsList()` | [/pokemon-habitat](https://pokeapi.co/api/v2/pokemon-habitat/) |
292 | | `getPokemonShapesList()` | [/pokemon-shape](https://pokeapi.co/api/v2/pokemon-shape/) |
293 | | `getPokemonSpeciesList()` | [/pokemon-species](https://pokeapi.co/api/v2/pokemon-species/) |
294 | | `getStatsList()` | [/stat](https://pokeapi.co/api/v2/stat/) |
295 | | `getTypesList()` | [/type](https://pokeapi.co/api/v2/type/) |
296 | | `getLanguagesList()` | [/language](https://pokeapi.co/api/v2/language/) |
297 |
298 | ### Custom URLs and paths
299 |
300 | Use `.resource()` to query any URL or path. Also this function accepts both single values and Arrays.
301 |
302 | ```js
303 | P.resource([
304 | "/api/v2/pokemon/36",
305 | "api/v2/berry/8",
306 | "https://pokeapi.co/api/v2/ability/9/",
307 | ]).then(function(response) {
308 | console.log(response)
309 | })
310 |
311 | P.resource("api/v2/berry/5").then(function(response) {
312 | console.log(response)
313 | })
314 | ```
315 |
316 | ## Internet Explorer 8
317 |
318 | In order to target this browser you must load a `Promise` polyfill before `pokeapi-js-wrapper`. You can choose one of your choice, we recommend [jakearchibald/es6-promise](https://cdnjs.com/libraries/es6-promise) or [stefanpenner/es6-promise](https://github.com/stefanpenner/es6-promise)
319 |
--------------------------------------------------------------------------------
/test/test.html.js:
--------------------------------------------------------------------------------
1 | describe("service worker", function () {
2 | it("should be activated on second run", function () {
3 | const P = new Pokedex.Pokedex({cacheImages: true});
4 | return navigator.serviceWorker.getRegistrations().then(function(registrations) {
5 | const sw = registrations.filter(function(serviceworker) {
6 | return serviceworker.active.scriptURL.endsWith('pokeapi-js-wrapper-sw.js')
7 | });
8 | expect(sw).to.have.lengthOf(1)
9 | expect(sw[0].active.state).to.be.equal('activated')
10 | });
11 | });
12 | });
13 |
14 | describe("pokedex", function () {
15 | var id = 2;
16 | defaultP = new Pokedex.Pokedex();
17 | customP = new Pokedex.Pokedex({
18 | protocol: 'https',
19 | offset: 10,
20 | limit: 1,
21 | timeout: 10000,
22 | cache: false,
23 | cacheImages: false
24 | });
25 | this.timeout(5000);
26 |
27 | describe(".resource(Mixed: array)", function () {
28 | it("should have property name", function () {
29 | return customP.resource(['/api/v2/pokemon/36', 'api/v2/berry/8', 'https://pokeapi.co/api/v2/ability/9/']).then(res => {
30 | expect(res[0]).to.have.property('name');
31 | expect(res[1]).to.have.property('name');
32 | expect(res[2]).to.have.property('name');
33 | })
34 | });
35 | });
36 |
37 | describe(".resource(Path: string)", function () {
38 | it("should have property height", function () {
39 | return defaultP.resource('/api/v2/pokemon/34').then(res => {
40 | expect(res).to.have.property('height');
41 | })
42 | });
43 | });
44 |
45 | describe(".resource(Url: string)", function () {
46 | it("should have property height", function () {
47 | return defaultP.resource('https://pokeapi.co/api/v2/pokemon/400').then(res => {
48 | expect(res).to.have.property('height')
49 | })
50 | });
51 | });
52 |
53 | describe(".getVersionByName(Id: int)", function () {
54 | it("should have property name", function () {
55 | return defaultP.getVersionByName(id).then(res => {
56 | expect(res).to.have.property("name");
57 | })
58 | });
59 | });
60 |
61 | // start root endpoints
62 |
63 | describe(".getEndpointsList() secure (with ssl)", function() {
64 | it("should have property pokedex", function() {
65 | return defaultP.getEndpointsList().then(res => {
66 | expect(res).to.have.property("pokedex");
67 | })
68 | });
69 | });
70 |
71 | describe(".getBerriesList() secure (with ssl)", function() {
72 | it("should have property count", function() {
73 | return defaultP.getBerriesList().then(res => {
74 | expect(res).to.have.property("count");
75 | })
76 | });
77 | });
78 |
79 | describe(".getBerriesFirmnesssList() secure (with ssl)", function() {
80 | it("should have property count", function() {
81 | return defaultP.getBerriesFirmnesssList().then(res => {
82 | expect(res).to.have.property("count");
83 | })
84 | });
85 | });
86 |
87 | describe(".getBerriesFlavorsList() secure (with ssl)", function() {
88 | it("should have property count", function() {
89 | return defaultP.getBerriesFlavorsList().then(res => {
90 | expect(res).to.have.property("count");
91 | })
92 | });
93 | });
94 |
95 | describe(".getContestTypesList() secure (with ssl)", function() {
96 | it("should have property count", function() {
97 | return defaultP.getContestTypesList().then(res => {
98 | expect(res).to.have.property("count");
99 | })
100 | });
101 | });
102 |
103 | describe(".getContestEffectsList() secure (with ssl)", function() {
104 | it("should have property count", function() {
105 | return defaultP.getContestEffectsList().then(res => {
106 | expect(res).to.have.property("count");
107 | })
108 | });
109 | });
110 |
111 | describe(".getSuperContestEffectsList() secure (with ssl)", function() {
112 | it("should have property count", function() {
113 | return defaultP.getSuperContestEffectsList().then(res => {
114 | expect(res).to.have.property("count");
115 | })
116 | });
117 | });
118 |
119 | describe(".getEncounterMethodsList() secure (with ssl)", function() {
120 | it("should have property count", function() {
121 | return defaultP.getEncounterMethodsList().then(res => {
122 | expect(res).to.have.property("count");
123 | })
124 | });
125 | });
126 |
127 | describe(".getEncounterConditionsList() secure (with ssl)", function() {
128 | it("should have property count", function() {
129 | return defaultP.getEncounterConditionsList().then(res => {
130 | expect(res).to.have.property("count");
131 | })
132 | });
133 | });
134 |
135 | describe(".getEncounterConditionValuesList() secure (with ssl)", function() {
136 | it("should have property count", function() {
137 | return defaultP.getEncounterConditionValuesList().then(res => {
138 | expect(res).to.have.property("count");
139 | })
140 | });
141 | });
142 |
143 | describe(".getEvolutionChainsList() secure (with ssl)", function() {
144 | it("should have property count", function() {
145 | return defaultP.getEvolutionChainsList().then(res => {
146 | expect(res).to.have.property("count");
147 | })
148 | });
149 | });
150 |
151 | describe(".getEvolutionTriggersList() secure (with ssl)", function() {
152 | it("should have property count", function() {
153 | return defaultP.getEvolutionTriggersList().then(res => {
154 | expect(res).to.have.property("count");
155 | })
156 | });
157 | });
158 |
159 | describe(".getGenerationsList() secure (with ssl)", function() {
160 | it("should have property count", function() {
161 | return defaultP.getGenerationsList().then(res => {
162 | expect(res).to.have.property("count");
163 | })
164 | });
165 | });
166 |
167 | describe(".getPokedexsList() secure (with ssl)", function() {
168 | it("should have property count", function() {
169 | return defaultP.getPokedexsList().then(res => {
170 | expect(res).to.have.property("count");
171 | })
172 | });
173 | });
174 |
175 | describe(".getVersionsList() secure (with ssl)", function() {
176 | it("should have property count", function() {
177 | return defaultP.getVersionsList().then(res => {
178 | expect(res).to.have.property("count");
179 | })
180 | });
181 | });
182 |
183 | describe(".getVersionGroupsList() secure (with ssl)", function() {
184 | it("should have property count", function() {
185 | return defaultP.getVersionGroupsList().then(res => {
186 | expect(res).to.have.property("count");
187 | })
188 | });
189 | });
190 |
191 | describe(".getItemsList() secure (with ssl)", function() {
192 | it("should have property count", function() {
193 | return defaultP.getItemsList().then(res => {
194 | expect(res).to.have.property("count");
195 | })
196 | });
197 | });
198 |
199 | describe(".getItemAttributesList() secure (with ssl)", function() {
200 | it("should have property count", function() {
201 | return defaultP.getItemAttributesList().then(res => {
202 | expect(res).to.have.property("count");
203 | })
204 | });
205 | });
206 |
207 | describe(".getItemCategoriesList() secure (with ssl)", function() {
208 | it("should have property count", function() {
209 | return defaultP.getItemCategoriesList().then(res => {
210 | expect(res).to.have.property("count");
211 | })
212 | });
213 | });
214 |
215 | describe(".getItemFlingEffectsList() secure (with ssl)", function() {
216 | it("should have property count", function() {
217 | return defaultP.getItemFlingEffectsList().then(res => {
218 | expect(res).to.have.property("count");
219 | })
220 | });
221 | });
222 |
223 | describe(".getItemPocketsList() secure (with ssl)", function() {
224 | it("should have property count", function() {
225 | return defaultP.getItemPocketsList().then(res => {
226 | expect(res).to.have.property("count");
227 | })
228 | });
229 | });
230 |
231 | describe(".getMachinesList() secure (with ssl)", function() {
232 | it("should have property count", function() {
233 | return defaultP.getMachinesList().then(res => {
234 | expect(res).to.have.property("count");
235 | })
236 | });
237 | });
238 |
239 | describe(".getMovesList() secure (with ssl)", function() {
240 | it("should have property count", function() {
241 | return defaultP.getMovesList().then(res => {
242 | expect(res).to.have.property("count");
243 | })
244 | });
245 | });
246 |
247 | describe(".getMoveAilmentsList() secure (with ssl)", function() {
248 | it("should have property count", function() {
249 | return defaultP.getMoveAilmentsList().then(res => {
250 | expect(res).to.have.property("count");
251 | })
252 | });
253 | });
254 |
255 | describe(".getMoveBattleStylesList() secure (with ssl)", function() {
256 | it("should have property count", function() {
257 | return defaultP.getMoveBattleStylesList().then(res => {
258 | expect(res).to.have.property("count");
259 | })
260 | });
261 | });
262 |
263 | describe(".getMoveCategoriesList() secure (with ssl)", function() {
264 | it("should have property count", function() {
265 | return defaultP.getMoveCategoriesList().then(res => {
266 | expect(res).to.have.property("count");
267 | })
268 | });
269 | });
270 |
271 | describe(".getMoveDamageClassesList() secure (with ssl)", function() {
272 | it("should have property count", function() {
273 | return defaultP.getMoveDamageClassesList().then(res => {
274 | expect(res).to.have.property("count");
275 | })
276 | });
277 | });
278 |
279 | describe(".getMoveLearnMethodsList() secure (with ssl)", function() {
280 | it("should have property count", function() {
281 | return defaultP.getMoveLearnMethodsList().then(res => {
282 | expect(res).to.have.property("count");
283 | })
284 | });
285 | });
286 |
287 | describe(".getMoveTargetsList() secure (with ssl)", function() {
288 | it("should have property count", function() {
289 | return defaultP.getMoveTargetsList().then(res => {
290 | expect(res).to.have.property("count");
291 | })
292 | });
293 | });
294 |
295 | describe(".getLocationsList() secure (with ssl)", function() {
296 | it("should have property count", function() {
297 | return defaultP.getLocationsList().then(res => {
298 | expect(res).to.have.property("count");
299 | })
300 | });
301 | });
302 |
303 | describe(".getLocationAreasList() secure (with ssl)", function() {
304 | it("should have property count", function() {
305 | return defaultP.getLocationAreasList().then(res => {
306 | expect(res).to.have.property("count");
307 | })
308 | });
309 | });
310 |
311 | describe(".getPalParkAreasList() secure (with ssl)", function() {
312 | it("should have property count", function() {
313 | return defaultP.getPalParkAreasList().then(res => {
314 | expect(res).to.have.property("count");
315 | })
316 | });
317 | });
318 |
319 | describe(".getRegionsList() secure (with ssl)", function() {
320 | it("should have property count", function() {
321 | return defaultP.getRegionsList().then(res => {
322 | expect(res).to.have.property("count");
323 | })
324 | });
325 | });
326 |
327 | describe(".getAbilitiesList() secure (with ssl)", function() {
328 | it("should have property count", function() {
329 | return defaultP.getAbilitiesList().then(res => {
330 | expect(res).to.have.property("count");
331 | })
332 | });
333 | });
334 |
335 | describe(".getCharacteristicsList() secure (with ssl)", function() {
336 | it("should have property count", function() {
337 | return defaultP.getCharacteristicsList().then(res => {
338 | expect(res).to.have.property("count");
339 | })
340 | });
341 | });
342 |
343 | describe(".getEggGroupsList() secure (with ssl)", function() {
344 | it("should have property count", function() {
345 | return defaultP.getEggGroupsList().then(res => {
346 | expect(res).to.have.property("count");
347 | })
348 | });
349 | });
350 |
351 | describe(".getGendersList() secure (with ssl)", function() {
352 | it("should have property count", function() {
353 | return defaultP.getGendersList().then(res => {
354 | expect(res).to.have.property("count");
355 | })
356 | });
357 | });
358 |
359 | describe(".getGrowthRatesList() secure (with ssl)", function() {
360 | it("should have property count", function() {
361 | return defaultP.getGrowthRatesList().then(res => {
362 | expect(res).to.have.property("count");
363 | })
364 | });
365 | });
366 |
367 | describe(".getNaturesList() secure (with ssl)", function() {
368 | it("should have property count", function() {
369 | return defaultP.getNaturesList().then(res => {
370 | expect(res).to.have.property("count");
371 | })
372 | });
373 | });
374 |
375 | describe(".getPokeathlonStatsList() secure (with ssl)", function() {
376 | it("should have property count", function() {
377 | return defaultP.getPokeathlonStatsList().then(res => {
378 | expect(res).to.have.property("count");
379 | })
380 | });
381 | });
382 |
383 | describe(".getPokemonsList() secure (with ssl)", function() {
384 | it("should have property count", function() {
385 | return defaultP.getPokemonsList().then(res => {
386 | expect(res).to.have.property("count");
387 | })
388 | });
389 | });
390 |
391 | describe(".getPokemonColorsList() secure (with ssl)", function() {
392 | it("should have property count", function() {
393 | return defaultP.getPokemonColorsList().then(res => {
394 | expect(res).to.have.property("count");
395 | })
396 | });
397 | });
398 |
399 | describe(".getPokemonFormsList() secure (with ssl)", function() {
400 | it("should have property count", function() {
401 | return defaultP.getPokemonFormsList().then(res => {
402 | expect(res).to.have.property("count");
403 | })
404 | });
405 | });
406 |
407 | describe(".getPokemonHabitatsList() secure (with ssl)", function() {
408 | it("should have property count", function() {
409 | return defaultP.getPokemonHabitatsList().then(res => {
410 | expect(res).to.have.property("count");
411 | })
412 | });
413 | });
414 |
415 | describe(".getPokemonShapesList() secure (with ssl)", function() {
416 | it("should have property count", function() {
417 | return defaultP.getPokemonShapesList().then(res => {
418 | expect(res).to.have.property("count");
419 | })
420 | });
421 | });
422 |
423 | describe(".getPokemonSpeciesList() secure (with ssl)", function() {
424 | it("should have property count", function() {
425 | return defaultP.getPokemonSpeciesList().then(res => {
426 | expect(res).to.have.property("count");
427 | })
428 | });
429 | });
430 |
431 | describe(".getStatsList() secure (with ssl)", function() {
432 | it("should have property count", function() {
433 | return defaultP.getStatsList().then(res => {
434 | expect(res).to.have.property("count");
435 | })
436 | });
437 | });
438 |
439 | describe(".getTypesList() secure (with ssl)", function() {
440 | it("should have property count", function() {
441 | return defaultP.getTypesList().then(res => {
442 | expect(res).to.have.property("count");
443 | })
444 | });
445 | });
446 |
447 | describe(".getLanguagesList() secure (with ssl)", function() {
448 | it("should have property count", function() {
449 | return defaultP.getLanguagesList().then(res => {
450 | expect(res).to.have.property("count");
451 | })
452 | });
453 | });
454 |
455 | // end root endpoints
456 |
457 | // start normals calls
458 |
459 | describe(".getBerryByName(Array: string)", function() {
460 | it("should have length 3", function() {
461 | return defaultP.getBerryByName(['cheri', 'chesto', 'pecha']).then(res => {
462 | expect(res).to.have.length(3);
463 | })
464 | });
465 | });
466 |
467 | describe(".getBerryByName(Array: int)", function() {
468 | it("should have length 3", function () {
469 | return defaultP.getBerryByName([1, 3, 5]).then(res => {
470 | expect(res).to.have.length(3);
471 | })
472 | });
473 | });
474 |
475 | describe(".getPokemonByName(Array: int)", function() {
476 | it("should have length 4", function() {
477 | return defaultP.getPokemonByName([15, 35, 433, 444]).then(res => {
478 | expect(res).to.have.length(4);
479 | })
480 | });
481 | });
482 |
483 | describe(".getBerryByName(Id: int)", function() {
484 | it("should have property name", function() {
485 | return defaultP.getBerryByName(id).then(res => {
486 | expect(res).to.have.property("name");
487 | })
488 | });
489 | });
490 |
491 | describe(".getBerryByName(Id: int) cached", function() {
492 | it("should have property name", function() {
493 | return defaultP.getBerryByName(id).then(res => {
494 | expect(res).to.have.property("name");
495 | })
496 | });
497 | });
498 |
499 | describe(".getBerryFirmnessByName(Id: int)", function() {
500 | it("should have property name", function() {
501 | return defaultP.getBerryFirmnessByName(id).then(res => {
502 | expect(res).to.have.property("name");
503 | })
504 | });
505 | });
506 |
507 | describe(".getBerryFlavorByName(Id: int)", function() {
508 | it("should have property name", function() {
509 | return defaultP.getBerryFlavorByName(id).then(res => {
510 | expect(res).to.have.property("name");
511 | })
512 | });
513 | });
514 |
515 | describe(".getContestTypeByName(Id: int)", function() {
516 | it("should have property name", function() {
517 | return defaultP.getContestTypeByName(id).then(res => {
518 | expect(res).to.have.property("name");
519 | })
520 | });
521 | });
522 |
523 | describe(".getContestEffectById(Id: int)", function() {
524 | it("should have property id", function() {
525 | return defaultP.getContestEffectById(id).then(res => {
526 | expect(res).to.have.property("id");
527 | })
528 | });
529 | });
530 |
531 | describe(".getSuperContestEffectById(Id: int)", function() {
532 | it("should have property id", function() {
533 | return defaultP.getSuperContestEffectById(id).then(res => {
534 | expect(res).to.have.property("id");
535 | })
536 | });
537 | });
538 |
539 | describe(".getEncounterMethodByName(Id: int)", function() {
540 | it("should have property name", function() {
541 | return defaultP.getEncounterMethodByName(id).then(res => {
542 | expect(res).to.have.property("name");
543 | })
544 | });
545 | });
546 |
547 | describe(".getEncounterConditionByName(Id: int)", function() {
548 | it("should have property name", function() {
549 | return defaultP.getEncounterConditionByName(id).then(res => {
550 | expect(res).to.have.property("name");
551 | })
552 | });
553 | });
554 |
555 | describe(".getEncounterConditionValueByName(Id: int)", function() {
556 | it("should have property name", function() {
557 | return defaultP.getEncounterConditionValueByName(id).then(res => {
558 | expect(res).to.have.property("name");
559 | })
560 | });
561 | });
562 |
563 | describe(".getEvolutionChainById(Id: int)", function() {
564 | it("should have property name", function() {
565 | return defaultP.getEvolutionChainById(id).then(res => {
566 | expect(res).to.have.property("id");
567 | })
568 | });
569 | });
570 |
571 | describe(".getEvolutionTriggerByName(Id: int)", function() {
572 | it("should have property name", function() {
573 | return defaultP.getEvolutionTriggerByName(id).then(res => {
574 | expect(res).to.have.property("name");
575 | })
576 | });
577 | });
578 |
579 | describe(".getGenerationByName(Id: int)", function() {
580 | it("should have property name", function() {
581 | return defaultP.getGenerationByName(id).then(res => {
582 | expect(res).to.have.property("name");
583 | })
584 | });
585 | });
586 |
587 | describe(".getPokedexByName(Id: int)", function() {
588 | it("should have property name", function() {
589 | return defaultP.getPokedexByName(id).then(res => {
590 | expect(res).to.have.property("name");
591 | })
592 | });
593 | });
594 |
595 | describe(".getVersionByName(Id: int)", function() {
596 | it("should have property name", function() {
597 | return defaultP.getVersionByName(id).then(res => {
598 | expect(res).to.have.property("name");
599 | })
600 | });
601 | });
602 |
603 | describe(".getVersionGroupByName(Id: int)", function() {
604 | it("should have property name", function() {
605 | return defaultP.getVersionGroupByName(id).then(res => {
606 | expect(res).to.have.property("name");
607 | })
608 | });
609 | });
610 |
611 | describe(".getItemByName(Id: int)", function() {
612 | it("should have property name", function() {
613 | return defaultP.getItemByName(id).then(res => {
614 | expect(res).to.have.property("name");
615 | })
616 | });
617 | });
618 |
619 | describe(".getItemAttributeByName(Id: int)", function() {
620 | it("should have property name", function() {
621 | return defaultP.getItemAttributeByName(id).then(res => {
622 | expect(res).to.have.property("name");
623 | })
624 | });
625 | });
626 |
627 | describe(".getItemCategoryByName(Id: int)", function() {
628 | it("should have property name", function() {
629 | return defaultP.getItemCategoryByName(id).then(res => {
630 | expect(res).to.have.property("name");
631 | })
632 | });
633 | });
634 |
635 | describe(".getItemFlingEffectByName(Id: int)", function() {
636 | it("should have property name", function() {
637 | return defaultP.getItemFlingEffectByName(id).then(res => {
638 | expect(res).to.have.property("name");
639 | })
640 | });
641 | });
642 |
643 | describe(".getItemPocketByName(Id: int)", function() {
644 | it("should have property name", function() {
645 | return defaultP.getItemPocketByName(id).then(res => {
646 | expect(res).to.have.property("name");
647 | })
648 | });
649 | });
650 |
651 | describe(".getMachineById(Id: int)", function() {
652 | it("should have property id", function() {
653 | return defaultP.getMachineById(id).then(res => {
654 | expect(res).to.have.property("id");
655 | })
656 | });
657 | });
658 |
659 | describe(".getMoveByName(Id: int)", function() {
660 | it("should have property name", function() {
661 | return defaultP.getMoveByName(id).then(res => {
662 | expect(res).to.have.property("name");
663 | })
664 | });
665 | });
666 |
667 | describe(".getMoveAilmentByName(Id: int)", function() {
668 | it("should have property name", function() {
669 | return defaultP.getMoveAilmentByName(id).then(res => {
670 | expect(res).to.have.property("name");
671 | })
672 | });
673 | });
674 |
675 | describe(".getMoveBattleStyleByName(Id: int)", function() {
676 | it("should have property name", function() {
677 | return defaultP.getMoveBattleStyleByName(id).then(res => {
678 | expect(res).to.have.property("name");
679 | })
680 | });
681 | });
682 |
683 | describe(".getMoveCategoryByName(Id: int)", function() {
684 | it("should have property name", function() {
685 | return defaultP.getMoveCategoryByName(id).then(res => {
686 | expect(res).to.have.property("name");
687 | })
688 | });
689 | });
690 |
691 | describe(".getMoveDamageClassByName(Id: int)", function() {
692 | it("should have property name", function() {
693 | return defaultP.getMoveDamageClassByName(id).then(res => {
694 | expect(res).to.have.property("name");
695 | })
696 | });
697 | });
698 |
699 | describe(".getMoveTargetByName(Id: int)", function() {
700 | it("should have property name", function() {
701 | return defaultP.getMoveTargetByName(id).then(res => {
702 | expect(res).to.have.property("name");
703 | })
704 | });
705 | });
706 |
707 | describe(".getLocationByName(Id: int)", function() {
708 | it("should have property name", function() {
709 | return defaultP.getLocationByName(id).then(res => {
710 | expect(res).to.have.property("name");
711 | })
712 | });
713 | });
714 |
715 | describe(".getLocationAreaByName(Id: int)", function() {
716 | it("should have property name", function() {
717 | return defaultP.getLocationAreaByName(id).then(res => {
718 | expect(res).to.have.property("name");
719 | })
720 | });
721 | });
722 |
723 | describe(".getPalParkAreaByName(Id: int)", function() {
724 | it("should have property name", function() {
725 | return defaultP.getPalParkAreaByName(id).then(res => {
726 | expect(res).to.have.property("name");
727 | })
728 | });
729 | });
730 |
731 | describe(".getRegionByName(Id: int)", function() {
732 | it("should have property name", function() {
733 | return defaultP.getRegionByName(id).then(res => {
734 | expect(res).to.have.property("name");
735 | })
736 | });
737 | });
738 |
739 | describe(".getAbilityByName(Id: int)", function() {
740 | it("should have property name", function() {
741 | return defaultP.getAbilityByName(id).then(res => {
742 | expect(res).to.have.property("name");
743 | })
744 | });
745 | });
746 |
747 | describe(".getCharacteristicById(Id: int)", function() {
748 | it("should have property name", function() {
749 | return defaultP.getCharacteristicById(id).then(res => {
750 | expect(res).to.have.property("id");
751 | })
752 | });
753 | });
754 |
755 | describe(".getEggGroupByName(Id: int)", function() {
756 | it("should have property name", function() {
757 | return defaultP.getEggGroupByName(id).then(res => {
758 | expect(res).to.have.property("name");
759 | })
760 | });
761 | });
762 |
763 | describe(".getGenderByName(Id: int)", function() {
764 | it("should have property name", function() {
765 | return defaultP.getGenderByName(id).then(res => {
766 | expect(res).to.have.property("name");
767 | })
768 | });
769 | });
770 |
771 | describe(".getGrowthRateByName(Id: int)", function() {
772 | it("should have property name", function() {
773 | return defaultP.getGrowthRateByName(id).then(res => {
774 | expect(res).to.have.property("name");
775 | })
776 | });
777 | });
778 |
779 | describe(".getNatureByName(Id: int)", function() {
780 | it("should have property name", function() {
781 | return defaultP.getNatureByName(id).then(res => {
782 | expect(res).to.have.property("name");
783 | })
784 | });
785 | });
786 |
787 | describe(".getPokeathlonStatByName(Id: int)", function() {
788 | it("should have property name", function() {
789 | return defaultP.getPokeathlonStatByName(id).then(res => {
790 | expect(res).to.have.property("name");
791 | })
792 | });
793 | });
794 |
795 | describe(".getPokemonByName(Id: int)", function() {
796 | it("should have property name", function() {
797 | return defaultP.getPokemonByName(id).then(res => {
798 | expect(res).to.have.property("name");
799 | })
800 | });
801 | });
802 |
803 | describe(".getPokemonColorByName(Id: int)", function() {
804 | it("should have property name", function() {
805 | return defaultP.getPokemonColorByName(id).then(res => {
806 | expect(res).to.have.property("name");
807 | })
808 | });
809 | });
810 |
811 | describe(".getPokemonFormByName(Id: int)", function() {
812 | it("should have property name", function() {
813 | return defaultP.getPokemonFormByName(id).then(res => {
814 | expect(res).to.have.property("name");
815 | })
816 | });
817 | });
818 |
819 | describe(".getPokemonHabitatByName(Id: int)", function() {
820 | it("should have property name", function() {
821 | return defaultP.getPokemonHabitatByName(id).then(res => {
822 | expect(res).to.have.property("name");
823 | })
824 | });
825 | });
826 |
827 | describe(".getPokemonShapeByName(Id: int)", function() {
828 | it("should have property name", function() {
829 | return defaultP.getPokemonShapeByName(id).then(res => {
830 | expect(res).to.have.property("name");
831 | })
832 | });
833 | });
834 |
835 | describe(".getPokemonSpeciesByName(Id: int)", function() {
836 | it("should have property name", function() {
837 | return defaultP.getPokemonSpeciesByName(id).then(res => {
838 | expect(res).to.have.property("name");
839 | })
840 | });
841 | });
842 |
843 | describe(".getStatByName(Id: int)", function() {
844 | it("should have property name", function() {
845 | return defaultP.getStatByName(id).then(res => {
846 | expect(res).to.have.property("name");
847 | })
848 | });
849 | });
850 |
851 | describe(".getTypeByName(Id: int)", function() {
852 | it("should have property name", function() {
853 | return defaultP.getTypeByName(id).then(res => {
854 | expect(res).to.have.property("name");
855 | })
856 | });
857 | });
858 |
859 | describe(".clearCache()", function () {
860 | it("should clear all cached entries", function () {
861 | return defaultP.clearCache().then(res => {
862 | defaultP.getCacheLength().then(length => {
863 | expect(length).to.be.equal(0);
864 | })
865 | })
866 | });
867 | });
868 |
869 | describe(".getLanguageByName(Id: int)", function() {
870 | it("should have property name", function() {
871 | return defaultP.getLanguageByName(id).then(res => {
872 | expect(res).to.have.property("name");
873 | })
874 | });
875 | });
876 | });
877 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | //var localStorage = require('localStorage');
2 | var Pokedex = require("../dist/index.js");
3 | var chai = require('chai'),
4 | expect = chai.expect,
5 | assert = chai.assert;
6 | chai.use(require("chai-things"));
7 | chai.use(require("chai-as-promised"));
8 |
9 | global.navigator = {
10 | userAgent: 'node.js'
11 | };
12 |
13 | global.window = {
14 | userAgent: 'node.js'
15 | };
16 |
17 | describe("pokedex", function () {
18 | var promise,
19 | id = 2,
20 | path = '/api/v2/pokemon/34',
21 | url = 'https://pokeapi.co/api/v2/pokemon/35',
22 | secureP = new Pokedex.Pokedex({cacheImages: true}),
23 | P = new Pokedex.Pokedex({
24 | protocol: 'https',
25 | offset: 10,
26 | limit: 1,
27 | timeout: 10000,
28 | cache: false
29 | }),
30 | interval = {
31 | limit: 10,
32 | offset: 34
33 | }
34 |
35 | this.timeout(21000);
36 |
37 | describe("P.getPokemonsList(interval: Interval) with default interval", function () {
38 | it("should succeed", function () {
39 | P.getPokemonsList().then(function(res) {
40 | expect(res).to.have.property('results');
41 | expect(res.results).to.have.lengthOf(1);
42 | expect(res.results[0].name).to.be.equal("caterpie");
43 | expect(res.results[0].name).not.to.be.equal("metapod");
44 | });
45 | });
46 | });
47 |
48 | describe(".getConfig()", function () {
49 | it("should return protocol property", function () {
50 | let config = P.getConfig()
51 | expect(config).to.have.property('protocol');
52 | });
53 | });
54 |
55 | describe(".getPokemonsList(interval: Interval) with interval", function () {
56 | before(function () {
57 | promise = secureP.getPokemonsList(interval);
58 | });
59 | it("should succeed", function () {
60 | return promise;
61 | });
62 | it("should have length results", function() {
63 | return expect(promise).to.eventually.have.property('results');
64 | });
65 | });
66 |
67 | describe(".clearCache()", function () {
68 | it("should clear all cached entries", function () {
69 | return P.clearCache().then(res => {
70 | P.getCacheLength().then(length => {
71 | expect(length).to.be.equal(0);
72 | })
73 | })
74 | });
75 | });
76 |
77 | describe(".resource(Mixed: array)", function () {
78 | before(function () {
79 | promise = secureP.resource(['/api/v2/pokemon/36', 'api/v2/berry/8', 'https://pokeapi.co/api/v2/ability/9/']);
80 | });
81 | it("should succeed", function () {
82 | return promise;
83 | });
84 | it("should have length 3", function() {
85 | return expect(promise).to.eventually.have.length(3);
86 | });
87 | it("should have property name", function () {
88 | return expect(promise).to.eventually.all.have.property('name');
89 | });
90 | });
91 |
92 | describe(".resource(Path: string)", function () {
93 | before(function () {
94 | promise = secureP.resource(path);
95 | });
96 | it("should succeed", function () {
97 | return promise;
98 | });
99 | it("should have property height", function () {
100 | return expect(promise).to.eventually.have.property('height');
101 | });
102 | });
103 |
104 | describe(".resource(Url: string)", function () {
105 | before(function () {
106 | promise = secureP.resource(url);
107 | });
108 | it("should succeed", function () {
109 | return promise;
110 | });
111 | it("should have property height", function () {
112 | return expect(promise).to.eventually.have.property('height')
113 | });
114 | });
115 |
116 | describe(".getPokemonEncounterAreasByName(Id: int)", function () {
117 | before(function () {
118 | promise = secureP.getPokemonEncounterAreasByName(id);
119 | });
120 | it("should succeed", function () {
121 | return promise;
122 | });
123 | it("should be an array", function () {
124 | return expect(promise).to.eventually.be.an("array");
125 | });
126 | });
127 |
128 | describe(".getVersionByName(Id: int)", function () {
129 | before(function () {
130 | promise = secureP.getVersionByName(id);
131 | });
132 | it("should succeed", function () {
133 | return promise;
134 | });
135 | it("should have property name", function () {
136 | return expect(promise).to.eventually.have.property("name");
137 | });
138 | });
139 |
140 | // start root endpoints
141 |
142 | describe(".getEndpointsList() secure (with ssl)", function() {
143 | before(function() {
144 | promise = secureP.getEndpointsList();
145 | });
146 | it("should succeed", function() {
147 | return promise;
148 | });
149 | it("should have property pokedex", function() {
150 | return expect(promise).to.eventually.have.property("pokedex");
151 | });
152 | });
153 |
154 | describe(".getBerriesList() secure (with ssl)", function() {
155 | before(function() {
156 | promise = secureP.getBerriesList();
157 | });
158 | it("should succeed", function() {
159 | return promise;
160 | });
161 | it("should have property count", function() {
162 | return expect(promise).to.eventually.have.property("count");
163 | });
164 | });
165 |
166 | describe(".getBerriesFirmnesssList() secure (with ssl)", function() {
167 | before(function() {
168 | promise = secureP.getBerriesFirmnesssList();
169 | });
170 | it("should succeed", function() {
171 | return promise;
172 | });
173 | it("should have property count", function() {
174 | return expect(promise).to.eventually.have.property("count");
175 | });
176 | });
177 |
178 | describe(".getBerriesFlavorsList() secure (with ssl)", function() {
179 | before(function() {
180 | promise = secureP.getBerriesFlavorsList();
181 | });
182 | it("should succeed", function() {
183 | return promise;
184 | });
185 | it("should have property count", function() {
186 | return expect(promise).to.eventually.have.property("count");
187 | });
188 | });
189 |
190 | describe(".getContestTypesList() secure (with ssl)", function() {
191 | before(function() {
192 | promise = secureP.getContestTypesList();
193 | });
194 | it("should succeed", function() {
195 | return promise;
196 | });
197 | it("should have property count", function() {
198 | return expect(promise).to.eventually.have.property("count");
199 | });
200 | });
201 |
202 | describe(".getContestEffectsList() secure (with ssl)", function() {
203 | before(function() {
204 | promise = secureP.getContestEffectsList();
205 | });
206 | it("should succeed", function() {
207 | return promise;
208 | });
209 | it("should have property count", function() {
210 | return expect(promise).to.eventually.have.property("count");
211 | });
212 | });
213 |
214 | describe(".getSuperContestEffectsList() secure (with ssl)", function() {
215 | before(function() {
216 | promise = secureP.getSuperContestEffectsList();
217 | });
218 | it("should succeed", function() {
219 | return promise;
220 | });
221 | it("should have property count", function() {
222 | return expect(promise).to.eventually.have.property("count");
223 | });
224 | });
225 |
226 | describe(".getEncounterMethodsList() secure (with ssl)", function() {
227 | before(function() {
228 | promise = secureP.getEncounterMethodsList();
229 | });
230 | it("should succeed", function() {
231 | return promise;
232 | });
233 | it("should have property count", function() {
234 | return expect(promise).to.eventually.have.property("count");
235 | });
236 | });
237 |
238 | describe(".getEncounterConditionsList() secure (with ssl)", function() {
239 | before(function() {
240 | promise = secureP.getEncounterConditionsList();
241 | });
242 | it("should succeed", function() {
243 | return promise;
244 | });
245 | it("should have property count", function() {
246 | return expect(promise).to.eventually.have.property("count");
247 | });
248 | });
249 |
250 | describe(".getEncounterConditionValuesList() secure (with ssl)", function() {
251 | before(function() {
252 | promise = secureP.getEncounterConditionValuesList();
253 | });
254 | it("should succeed", function() {
255 | return promise;
256 | });
257 | it("should have property count", function() {
258 | return expect(promise).to.eventually.have.property("count");
259 | });
260 | });
261 |
262 | describe(".getEvolutionChainsList() secure (with ssl)", function() {
263 | before(function() {
264 | promise = secureP.getEvolutionChainsList();
265 | });
266 | it("should succeed", function() {
267 | return promise;
268 | });
269 | it("should have property count", function() {
270 | return expect(promise).to.eventually.have.property("count");
271 | });
272 | });
273 |
274 | describe(".getEvolutionTriggersList() secure (with ssl)", function() {
275 | before(function() {
276 | promise = secureP.getEvolutionTriggersList();
277 | });
278 | it("should succeed", function() {
279 | return promise;
280 | });
281 | it("should have property count", function() {
282 | return expect(promise).to.eventually.have.property("count");
283 | });
284 | });
285 |
286 | describe(".getGenerationsList() secure (with ssl)", function() {
287 | before(function() {
288 | promise = secureP.getGenerationsList();
289 | });
290 | it("should succeed", function() {
291 | return promise;
292 | });
293 | it("should have property count", function() {
294 | return expect(promise).to.eventually.have.property("count");
295 | });
296 | });
297 |
298 | describe(".getPokedexsList() secure (with ssl)", function() {
299 | before(function() {
300 | promise = secureP.getPokedexsList();
301 | });
302 | it("should succeed", function() {
303 | return promise;
304 | });
305 | it("should have property count", function() {
306 | return expect(promise).to.eventually.have.property("count");
307 | });
308 | });
309 |
310 | describe(".getVersionsList() secure (with ssl)", function() {
311 | before(function() {
312 | promise = secureP.getVersionsList();
313 | });
314 | it("should succeed", function() {
315 | return promise;
316 | });
317 | it("should have property count", function() {
318 | return expect(promise).to.eventually.have.property("count");
319 | });
320 | });
321 |
322 | describe(".getVersionGroupsList() secure (with ssl)", function() {
323 | before(function() {
324 | promise = secureP.getVersionGroupsList();
325 | });
326 | it("should succeed", function() {
327 | return promise;
328 | });
329 | it("should have property count", function() {
330 | return expect(promise).to.eventually.have.property("count");
331 | });
332 | });
333 |
334 | describe(".getItemsList() secure (with ssl)", function() {
335 | before(function() {
336 | promise = secureP.getItemsList();
337 | });
338 | it("should succeed", function() {
339 | return promise;
340 | });
341 | it("should have property count", function() {
342 | return expect(promise).to.eventually.have.property("count");
343 | });
344 | });
345 |
346 | describe(".getItemAttributesList() secure (with ssl)", function() {
347 | before(function() {
348 | promise = secureP.getItemAttributesList();
349 | });
350 | it("should succeed", function() {
351 | return promise;
352 | });
353 | it("should have property count", function() {
354 | return expect(promise).to.eventually.have.property("count");
355 | });
356 | });
357 |
358 | describe(".getItemCategoriesList() secure (with ssl)", function() {
359 | before(function() {
360 | promise = secureP.getItemCategoriesList();
361 | });
362 | it("should succeed", function() {
363 | return promise;
364 | });
365 | it("should have property count", function() {
366 | return expect(promise).to.eventually.have.property("count");
367 | });
368 | });
369 |
370 | describe(".getItemFlingEffectsList() secure (with ssl)", function() {
371 | before(function() {
372 | promise = secureP.getItemFlingEffectsList();
373 | });
374 | it("should succeed", function() {
375 | return promise;
376 | });
377 | it("should have property count", function() {
378 | return expect(promise).to.eventually.have.property("count");
379 | });
380 | });
381 |
382 | describe(".getItemPocketsList() secure (with ssl)", function() {
383 | before(function() {
384 | promise = secureP.getItemPocketsList();
385 | });
386 | it("should succeed", function() {
387 | return promise;
388 | });
389 | it("should have property count", function() {
390 | return expect(promise).to.eventually.have.property("count");
391 | });
392 | });
393 |
394 | describe(".getMachinesList() secure (with ssl)", function() {
395 | before(function() {
396 | promise = secureP.getMachinesList();
397 | });
398 | it("should succeed", function() {
399 | return promise;
400 | });
401 | it("should have property count", function() {
402 | return expect(promise).to.eventually.have.property("count");
403 | });
404 | });
405 |
406 | describe(".getMovesList() secure (with ssl)", function() {
407 | before(function() {
408 | promise = secureP.getMovesList();
409 | });
410 | it("should succeed", function() {
411 | return promise;
412 | });
413 | it("should have property count", function() {
414 | return expect(promise).to.eventually.have.property("count");
415 | });
416 | });
417 |
418 | describe(".getMoveAilmentsList() secure (with ssl)", function() {
419 | before(function() {
420 | promise = secureP.getMoveAilmentsList();
421 | });
422 | it("should succeed", function() {
423 | return promise;
424 | });
425 | it("should have property count", function() {
426 | return expect(promise).to.eventually.have.property("count");
427 | });
428 | });
429 |
430 | describe(".getMoveBattleStylesList() secure (with ssl)", function() {
431 | before(function() {
432 | promise = secureP.getMoveBattleStylesList();
433 | });
434 | it("should succeed", function() {
435 | return promise;
436 | });
437 | it("should have property count", function() {
438 | return expect(promise).to.eventually.have.property("count");
439 | });
440 | });
441 |
442 | describe(".getMoveCategoriesList() secure (with ssl)", function() {
443 | before(function() {
444 | promise = secureP.getMoveCategoriesList();
445 | });
446 | it("should succeed", function() {
447 | return promise;
448 | });
449 | it("should have property count", function() {
450 | return expect(promise).to.eventually.have.property("count");
451 | });
452 | });
453 |
454 | describe(".getMoveDamageClassesList() secure (with ssl)", function() {
455 | before(function() {
456 | promise = secureP.getMoveDamageClassesList();
457 | });
458 | it("should succeed", function() {
459 | return promise;
460 | });
461 | it("should have property count", function() {
462 | return expect(promise).to.eventually.have.property("count");
463 | });
464 | });
465 |
466 | describe(".getMoveLearnMethodsList() secure (with ssl)", function() {
467 | before(function() {
468 | promise = secureP.getMoveLearnMethodsList();
469 | });
470 | it("should succeed", function() {
471 | return promise;
472 | });
473 | it("should have property count", function() {
474 | return expect(promise).to.eventually.have.property("count");
475 | });
476 | });
477 |
478 | describe(".getMoveTargetsList() secure (with ssl)", function() {
479 | before(function() {
480 | promise = secureP.getMoveTargetsList();
481 | });
482 | it("should succeed", function() {
483 | return promise;
484 | });
485 | it("should have property count", function() {
486 | return expect(promise).to.eventually.have.property("count");
487 | });
488 | });
489 |
490 | describe(".getLocationsList() secure (with ssl)", function() {
491 | before(function() {
492 | promise = secureP.getLocationsList();
493 | });
494 | it("should succeed", function() {
495 | return promise;
496 | });
497 | it("should have property count", function() {
498 | return expect(promise).to.eventually.have.property("count");
499 | });
500 | });
501 |
502 | describe(".getLocationAreasList() secure (with ssl)", function() {
503 | before(function() {
504 | promise = secureP.getLocationAreasList();
505 | });
506 | it("should succeed", function() {
507 | return promise;
508 | });
509 | it("should have property count", function() {
510 | return expect(promise).to.eventually.have.property("count");
511 | });
512 | });
513 |
514 | describe(".getPalParkAreasList() secure (with ssl)", function() {
515 | before(function() {
516 | promise = secureP.getPalParkAreasList();
517 | });
518 | it("should succeed", function() {
519 | return promise;
520 | });
521 | it("should have property count", function() {
522 | return expect(promise).to.eventually.have.property("count");
523 | });
524 | });
525 |
526 | describe(".getRegionsList() secure (with ssl)", function() {
527 | before(function() {
528 | promise = secureP.getRegionsList();
529 | });
530 | it("should succeed", function() {
531 | return promise;
532 | });
533 | it("should have property count", function() {
534 | return expect(promise).to.eventually.have.property("count");
535 | });
536 | });
537 |
538 | describe(".getAbilitiesList() secure (with ssl)", function() {
539 | before(function() {
540 | promise = secureP.getAbilitiesList();
541 | });
542 | it("should succeed", function() {
543 | return promise;
544 | });
545 | it("should have property count", function() {
546 | return expect(promise).to.eventually.have.property("count");
547 | });
548 | });
549 |
550 | describe(".getCharacteristicsList() secure (with ssl)", function() {
551 | before(function() {
552 | promise = secureP.getCharacteristicsList();
553 | });
554 | it("should succeed", function() {
555 | return promise;
556 | });
557 | it("should have property count", function() {
558 | return expect(promise).to.eventually.have.property("count");
559 | });
560 | });
561 |
562 | describe(".getEggGroupsList() secure (with ssl)", function() {
563 | before(function() {
564 | promise = secureP.getEggGroupsList();
565 | });
566 | it("should succeed", function() {
567 | return promise;
568 | });
569 | it("should have property count", function() {
570 | return expect(promise).to.eventually.have.property("count");
571 | });
572 | });
573 |
574 | describe(".getGendersList() secure (with ssl)", function() {
575 | before(function() {
576 | promise = secureP.getGendersList();
577 | });
578 | it("should succeed", function() {
579 | return promise;
580 | });
581 | it("should have property count", function() {
582 | return expect(promise).to.eventually.have.property("count");
583 | });
584 | });
585 |
586 | describe(".getGrowthRatesList() secure (with ssl)", function() {
587 | before(function() {
588 | promise = secureP.getGrowthRatesList();
589 | });
590 | it("should succeed", function() {
591 | return promise;
592 | });
593 | it("should have property count", function() {
594 | return expect(promise).to.eventually.have.property("count");
595 | });
596 | });
597 |
598 | describe(".getNaturesList() secure (with ssl)", function() {
599 | before(function() {
600 | promise = secureP.getNaturesList();
601 | });
602 | it("should succeed", function() {
603 | return promise;
604 | });
605 | it("should have property count", function() {
606 | return expect(promise).to.eventually.have.property("count");
607 | });
608 | });
609 |
610 | describe(".getPokeathlonStatsList() secure (with ssl)", function() {
611 | before(function() {
612 | promise = secureP.getPokeathlonStatsList();
613 | });
614 | it("should succeed", function() {
615 | return promise;
616 | });
617 | it("should have property count", function() {
618 | return expect(promise).to.eventually.have.property("count");
619 | });
620 | });
621 |
622 | describe(".getPokemonsList() secure (with ssl)", function() {
623 | before(function() {
624 | promise = secureP.getPokemonsList();
625 | });
626 | it("should succeed", function() {
627 | return promise;
628 | });
629 | it("should have property count", function() {
630 | return expect(promise).to.eventually.have.property("count");
631 | });
632 | });
633 |
634 | describe(".getPokemonColorsList() secure (with ssl)", function() {
635 | before(function() {
636 | promise = secureP.getPokemonColorsList();
637 | });
638 | it("should succeed", function() {
639 | return promise;
640 | });
641 | it("should have property count", function() {
642 | return expect(promise).to.eventually.have.property("count");
643 | });
644 | });
645 |
646 | describe(".getPokemonFormsList() secure (with ssl)", function() {
647 | before(function() {
648 | promise = secureP.getPokemonFormsList();
649 | });
650 | it("should succeed", function() {
651 | return promise;
652 | });
653 | it("should have property count", function() {
654 | return expect(promise).to.eventually.have.property("count");
655 | });
656 | });
657 |
658 | describe(".getPokemonHabitatsList() secure (with ssl)", function() {
659 | before(function() {
660 | promise = secureP.getPokemonHabitatsList();
661 | });
662 | it("should succeed", function() {
663 | return promise;
664 | });
665 | it("should have property count", function() {
666 | return expect(promise).to.eventually.have.property("count");
667 | });
668 | });
669 |
670 | describe(".getPokemonShapesList() secure (with ssl)", function() {
671 | before(function() {
672 | promise = secureP.getPokemonShapesList();
673 | });
674 | it("should succeed", function() {
675 | return promise;
676 | });
677 | it("should have property count", function() {
678 | return expect(promise).to.eventually.have.property("count");
679 | });
680 | });
681 |
682 | describe(".getPokemonSpeciesList() secure (with ssl)", function() {
683 | before(function() {
684 | promise = secureP.getPokemonSpeciesList();
685 | });
686 | it("should succeed", function() {
687 | return promise;
688 | });
689 | it("should have property count", function() {
690 | return expect(promise).to.eventually.have.property("count");
691 | });
692 | });
693 |
694 | describe(".getStatsList() secure (with ssl)", function() {
695 | before(function() {
696 | promise = secureP.getStatsList();
697 | });
698 | it("should succeed", function() {
699 | return promise;
700 | });
701 | it("should have property count", function() {
702 | return expect(promise).to.eventually.have.property("count");
703 | });
704 | });
705 |
706 | describe(".getTypesList() secure (with ssl)", function() {
707 | before(function() {
708 | promise = secureP.getTypesList();
709 | });
710 | it("should succeed", function() {
711 | return promise;
712 | });
713 | it("should have property count", function() {
714 | return expect(promise).to.eventually.have.property("count");
715 | });
716 | });
717 |
718 | describe(".getLanguagesList() secure (with ssl)", function() {
719 | before(function() {
720 | promise = secureP.getLanguagesList();
721 | });
722 | it("should succeed", function() {
723 | return promise;
724 | });
725 | it("should have property count", function() {
726 | return expect(promise).to.eventually.have.property("count");
727 | });
728 | });
729 |
730 | // end root endpoints
731 |
732 | // start normals calls
733 |
734 | describe(".getBerryByName(Array: string)", function() {
735 | before(function() {
736 | promise = secureP.getBerryByName(['cheri', 'chesto', 'pecha']);
737 | });
738 | it("should succeed", function() {
739 | return promise;
740 | });
741 | it("should have length 3", function() {
742 | return expect(promise).to.eventually.have.length(3);
743 | });
744 | it("berries should have property growth_time", function() {
745 | return expect(promise).to.eventually.all.have.property('growth_time');
746 | });
747 | });
748 |
749 | describe(".getBerryByName(Array: int)", function() {
750 | before(function() {
751 | promise = secureP.getBerryByName([1, 3, 5]);
752 | });
753 | it("should succeed", function() {
754 | return promise;
755 | });
756 | it("should have length 3", function() {
757 | return expect(promise).to.eventually.have.length(3);
758 | });
759 | it("berries should have property growth_time", function() {
760 | return expect(promise).to.eventually.all.have.property('growth_time');
761 | });
762 | });
763 |
764 | describe(".getPokemonByName(Array: int)", function() {
765 | before(function() {
766 | promise = secureP.getPokemonByName([15, 35, 433, 444]);
767 | });
768 | it("should succeed", function() {
769 | return promise;
770 | });
771 | it("should have length 4", function() {
772 | return expect(promise).to.eventually.have.length(4);
773 | });
774 | it("pokemons should have property height", function() {
775 | return expect(promise).to.eventually.all.have.property('height');
776 | });
777 | });
778 |
779 | describe(".getBerryByName(Id: int)", function() {
780 | before(function() {
781 | promise = secureP.getBerryByName(id);
782 | });
783 | it("should succeed", function() {
784 | return promise;
785 | });
786 | it("should have property name", function() {
787 | return expect(promise).to.eventually.have.property("name");
788 | });
789 | });
790 |
791 | describe(".getBerryByName(Id: int) cached", function() {
792 | before(function() {
793 | promise = secureP.getBerryByName(id);
794 | });
795 | it("should succeed", function() {
796 | return promise;
797 | });
798 | it("should have property name", function() {
799 | return expect(promise).to.eventually.have.property("name");
800 | });
801 | });
802 |
803 | describe(".getBerryFirmnessByName(Id: int)", function() {
804 | before(function() {
805 | promise = secureP.getBerryFirmnessByName(id);
806 | });
807 | it("should succeed", function() {
808 | return promise;
809 | });
810 | it("should have property name", function() {
811 | return expect(promise).to.eventually.have.property("name");
812 | });
813 | });
814 |
815 | describe(".getBerryFlavorByName(Id: int)", function() {
816 | before(function() {
817 | promise = secureP.getBerryFlavorByName(id);
818 | });
819 | it("should succeed", function() {
820 | return promise;
821 | });
822 | it("should have property name", function() {
823 | return expect(promise).to.eventually.have.property("name");
824 | });
825 | });
826 |
827 | describe(".getContestTypeByName(Id: int)", function() {
828 | before(function() {
829 | promise = secureP.getContestTypeByName(id);
830 | });
831 | it("should succeed", function() {
832 | return promise;
833 | });
834 | it("should have property name", function() {
835 | return expect(promise).to.eventually.have.property("name");
836 | });
837 | });
838 |
839 | describe(".getContestEffectById(Id: int)", function() {
840 | before(function() {
841 | promise = secureP.getContestEffectById(id);
842 | });
843 | it("should succeed", function() {
844 | return promise;
845 | });
846 | it("should have property id", function() {
847 | return expect(promise).to.eventually.have.property("id");
848 | });
849 | });
850 |
851 | describe(".getSuperContestEffectById(Id: int)", function() {
852 | before(function() {
853 | promise = secureP.getSuperContestEffectById(id);
854 | });
855 | it("should succeed", function() {
856 | return promise;
857 | });
858 | it("should have property id", function() {
859 | return expect(promise).to.eventually.have.property("id");
860 | });
861 | });
862 |
863 | describe(".getEncounterMethodByName(Id: int)", function() {
864 | before(function() {
865 | promise = secureP.getEncounterMethodByName(id);
866 | });
867 | it("should succeed", function() {
868 | return promise;
869 | });
870 | it("should have property name", function() {
871 | return expect(promise).to.eventually.have.property("name");
872 | });
873 | });
874 |
875 | describe(".getEncounterConditionByName(Id: int)", function() {
876 | before(function() {
877 | promise = secureP.getEncounterConditionByName(id);
878 | });
879 | it("should succeed", function() {
880 | return promise;
881 | });
882 | it("should have property name", function() {
883 | return expect(promise).to.eventually.have.property("name");
884 | });
885 | });
886 |
887 | describe(".getEncounterConditionValueByName(Id: int)", function() {
888 | before(function() {
889 | promise = secureP.getEncounterConditionValueByName(id);
890 | });
891 | it("should succeed", function() {
892 | return promise;
893 | });
894 | it("should have property name", function() {
895 | return expect(promise).to.eventually.have.property("name");
896 | });
897 | });
898 |
899 | describe(".getEvolutionChainById(Id: int)", function() {
900 | before(function() {
901 | promise = secureP.getEvolutionChainById(id);
902 | });
903 | it("should succeed", function() {
904 | return promise;
905 | });
906 | it("should have property name", function() {
907 | return expect(promise).to.eventually.have.property("id");
908 | });
909 | });
910 |
911 | describe(".getEvolutionTriggerByName(Id: int)", function() {
912 | before(function() {
913 | promise = secureP.getEvolutionTriggerByName(id);
914 | });
915 | it("should succeed", function() {
916 | return promise;
917 | });
918 | it("should have property name", function() {
919 | return expect(promise).to.eventually.have.property("name");
920 | });
921 | });
922 |
923 | describe(".getGenerationByName(Id: int)", function() {
924 | before(function() {
925 | promise = secureP.getGenerationByName(id);
926 | });
927 | it("should succeed", function() {
928 | return promise;
929 | });
930 | it("should have property name", function() {
931 | return expect(promise).to.eventually.have.property("name");
932 | });
933 | });
934 |
935 | describe(".getPokedexByName(Id: int)", function() {
936 | before(function() {
937 | promise = secureP.getPokedexByName(id);
938 | });
939 | it("should succeed", function() {
940 | return promise;
941 | });
942 | it("should have property name", function() {
943 | return expect(promise).to.eventually.have.property("name");
944 | });
945 | });
946 |
947 | describe(".getVersionByName(Id: int)", function() {
948 | before(function() {
949 | promise = secureP.getVersionByName(id);
950 | });
951 | it("should succeed", function() {
952 | return promise;
953 | });
954 | it("should have property name", function() {
955 | return expect(promise).to.eventually.have.property("name");
956 | });
957 | });
958 |
959 | describe(".getVersionGroupByName(Id: int)", function() {
960 | before(function() {
961 | promise = secureP.getVersionGroupByName(id);
962 | });
963 | it("should succeed", function() {
964 | return promise;
965 | });
966 | it("should have property name", function() {
967 | return expect(promise).to.eventually.have.property("name");
968 | });
969 | });
970 |
971 | describe(".getItemByName(Id: int)", function() {
972 | before(function() {
973 | promise = secureP.getItemByName(id);
974 | });
975 | it("should succeed", function() {
976 | return promise;
977 | });
978 | it("should have property name", function() {
979 | return expect(promise).to.eventually.have.property("name");
980 | });
981 | });
982 |
983 | describe(".getItemAttributeByName(Id: int)", function() {
984 | before(function() {
985 | promise = secureP.getItemAttributeByName(id);
986 | });
987 | it("should succeed", function() {
988 | return promise;
989 | });
990 | it("should have property name", function() {
991 | return expect(promise).to.eventually.have.property("name");
992 | });
993 | });
994 |
995 | describe(".getItemCategoryByName(Id: int)", function() {
996 | before(function() {
997 | promise = secureP.getItemCategoryByName(id);
998 | });
999 | it("should succeed", function() {
1000 | return promise;
1001 | });
1002 | it("should have property name", function() {
1003 | return expect(promise).to.eventually.have.property("name");
1004 | });
1005 | });
1006 |
1007 | describe(".getItemFlingEffectByName(Id: int)", function() {
1008 | before(function() {
1009 | promise = secureP.getItemFlingEffectByName(id);
1010 | });
1011 | it("should succeed", function() {
1012 | return promise;
1013 | });
1014 | it("should have property name", function() {
1015 | return expect(promise).to.eventually.have.property("name");
1016 | });
1017 | });
1018 |
1019 | describe(".getItemPocketByName(Id: int)", function() {
1020 | before(function() {
1021 | promise = secureP.getItemPocketByName(id);
1022 | });
1023 | it("should succeed", function() {
1024 | return promise;
1025 | });
1026 | it("should have property name", function() {
1027 | return expect(promise).to.eventually.have.property("name");
1028 | });
1029 | });
1030 |
1031 | describe(".getMachineById(Id: int)", function() {
1032 | before(function() {
1033 | promise = secureP.getMachineById(id);
1034 | });
1035 | it("should succeed", function() {
1036 | return promise;
1037 | });
1038 | it("should have property id", function() {
1039 | return expect(promise).to.eventually.have.property("id");
1040 | });
1041 | });
1042 |
1043 | describe(".getMoveByName(Id: int)", function() {
1044 | before(function() {
1045 | promise = secureP.getMoveByName(id);
1046 | });
1047 | it("should succeed", function() {
1048 | return promise;
1049 | });
1050 | it("should have property name", function() {
1051 | return expect(promise).to.eventually.have.property("name");
1052 | });
1053 | });
1054 |
1055 | describe(".getMoveAilmentByName(Id: int)", function() {
1056 | before(function() {
1057 | promise = secureP.getMoveAilmentByName(id);
1058 | });
1059 | it("should succeed", function() {
1060 | return promise;
1061 | });
1062 | it("should have property name", function() {
1063 | return expect(promise).to.eventually.have.property("name");
1064 | });
1065 | });
1066 |
1067 | describe(".getMoveBattleStyleByName(Id: int)", function() {
1068 | before(function() {
1069 | promise = secureP.getMoveBattleStyleByName(id);
1070 | });
1071 | it("should succeed", function() {
1072 | return promise;
1073 | });
1074 | it("should have property name", function() {
1075 | return expect(promise).to.eventually.have.property("name");
1076 | });
1077 | });
1078 |
1079 | describe(".getMoveCategoryByName(Id: int)", function() {
1080 | before(function() {
1081 | promise = secureP.getMoveCategoryByName(id);
1082 | });
1083 | it("should succeed", function() {
1084 | return promise;
1085 | });
1086 | it("should have property name", function() {
1087 | return expect(promise).to.eventually.have.property("name");
1088 | });
1089 | });
1090 |
1091 | describe(".getMoveDamageClassByName(Id: int)", function() {
1092 | before(function() {
1093 | promise = secureP.getMoveDamageClassByName(id);
1094 | });
1095 | it("should succeed", function() {
1096 | return promise;
1097 | });
1098 | it("should have property name", function() {
1099 | return expect(promise).to.eventually.have.property("name");
1100 | });
1101 | });
1102 |
1103 | describe(".getMoveTargetByName(Id: int)", function() {
1104 | before(function() {
1105 | promise = secureP.getMoveTargetByName(id);
1106 | });
1107 | it("should succeed", function() {
1108 | return promise;
1109 | });
1110 | it("should have property name", function() {
1111 | return expect(promise).to.eventually.have.property("name");
1112 | });
1113 | });
1114 |
1115 | describe(".getLocationByName(Id: int)", function() {
1116 | before(function() {
1117 | promise = secureP.getLocationByName(id);
1118 | });
1119 | it("should succeed", function() {
1120 | return promise;
1121 | });
1122 | it("should have property name", function() {
1123 | return expect(promise).to.eventually.have.property("name");
1124 | });
1125 | });
1126 |
1127 | describe(".getLocationAreaByName(Id: int)", function() {
1128 | before(function() {
1129 | promise = secureP.getLocationAreaByName(id);
1130 | });
1131 | it("should succeed", function() {
1132 | return promise;
1133 | });
1134 | it("should have property name", function() {
1135 | return expect(promise).to.eventually.have.property("name");
1136 | });
1137 | });
1138 |
1139 | describe(".getPalParkAreaByName(Id: int)", function() {
1140 | before(function() {
1141 | promise = secureP.getPalParkAreaByName(id);
1142 | });
1143 | it("should succeed", function() {
1144 | return promise;
1145 | });
1146 | it("should have property name", function() {
1147 | return expect(promise).to.eventually.have.property("name");
1148 | });
1149 | });
1150 |
1151 | describe(".getRegionByName(Id: int)", function() {
1152 | before(function() {
1153 | promise = secureP.getRegionByName(id);
1154 | });
1155 | it("should succeed", function() {
1156 | return promise;
1157 | });
1158 | it("should have property name", function() {
1159 | return expect(promise).to.eventually.have.property("name");
1160 | });
1161 | });
1162 |
1163 | describe(".getAbilityByName(Id: int)", function() {
1164 | before(function() {
1165 | promise = secureP.getAbilityByName(id);
1166 | });
1167 | it("should succeed", function() {
1168 | return promise;
1169 | });
1170 | it("should have property name", function() {
1171 | return expect(promise).to.eventually.have.property("name");
1172 | });
1173 | });
1174 |
1175 | describe(".getCharacteristicById(Id: int)", function() {
1176 | before(function() {
1177 | promise = secureP.getCharacteristicById(id);
1178 | });
1179 | it("should succeed", function() {
1180 | return promise;
1181 | });
1182 | it("should have property name", function() {
1183 | return expect(promise).to.eventually.have.property("id");
1184 | });
1185 | });
1186 |
1187 | describe(".getEggGroupByName(Id: int)", function() {
1188 | before(function() {
1189 | promise = secureP.getEggGroupByName(id);
1190 | });
1191 | it("should succeed", function() {
1192 | return promise;
1193 | });
1194 | it("should have property name", function() {
1195 | return expect(promise).to.eventually.have.property("name");
1196 | });
1197 | });
1198 |
1199 | describe(".getGenderByName(Id: int)", function() {
1200 | before(function() {
1201 | promise = secureP.getGenderByName(id);
1202 | });
1203 | it("should succeed", function() {
1204 | return promise;
1205 | });
1206 | it("should have property name", function() {
1207 | return expect(promise).to.eventually.have.property("name");
1208 | });
1209 | });
1210 |
1211 | describe(".getGrowthRateByName(Id: int)", function() {
1212 | before(function() {
1213 | promise = secureP.getGrowthRateByName(id);
1214 | });
1215 | it("should succeed", function() {
1216 | return promise;
1217 | });
1218 | it("should have property name", function() {
1219 | return expect(promise).to.eventually.have.property("name");
1220 | });
1221 | });
1222 |
1223 | describe(".getNatureByName(Id: int)", function() {
1224 | before(function() {
1225 | promise = secureP.getNatureByName(id);
1226 | });
1227 | it("should succeed", function() {
1228 | return promise;
1229 | });
1230 | it("should have property name", function() {
1231 | return expect(promise).to.eventually.have.property("name");
1232 | });
1233 | });
1234 |
1235 | describe(".getPokeathlonStatByName(Id: int)", function() {
1236 | before(function() {
1237 | promise = secureP.getPokeathlonStatByName(id);
1238 | });
1239 | it("should succeed", function() {
1240 | return promise;
1241 | });
1242 | it("should have property name", function() {
1243 | return expect(promise).to.eventually.have.property("name");
1244 | });
1245 | });
1246 |
1247 | describe(".getPokemonByName(Id: int)", function() {
1248 | before(function() {
1249 | promise = secureP.getPokemonByName(id);
1250 | });
1251 | it("should succeed", function() {
1252 | return promise;
1253 | });
1254 | it("should have property name", function() {
1255 | return expect(promise).to.eventually.have.property("name");
1256 | });
1257 | });
1258 |
1259 | describe(".getPokemonColorByName(Id: int)", function() {
1260 | before(function() {
1261 | promise = secureP.getPokemonColorByName(id);
1262 | });
1263 | it("should succeed", function() {
1264 | return promise;
1265 | });
1266 | it("should have property name", function() {
1267 | return expect(promise).to.eventually.have.property("name");
1268 | });
1269 | });
1270 |
1271 | describe(".getPokemonFormByName(Id: int)", function() {
1272 | before(function() {
1273 | promise = secureP.getPokemonFormByName(id);
1274 | });
1275 | it("should succeed", function() {
1276 | return promise;
1277 | });
1278 | it("should have property name", function() {
1279 | return expect(promise).to.eventually.have.property("name");
1280 | });
1281 | });
1282 |
1283 | describe(".getPokemonHabitatByName(Id: int)", function() {
1284 | before(function() {
1285 | promise = secureP.getPokemonHabitatByName(id);
1286 | });
1287 | it("should succeed", function() {
1288 | return promise;
1289 | });
1290 | it("should have property name", function() {
1291 | return expect(promise).to.eventually.have.property("name");
1292 | });
1293 | });
1294 |
1295 | describe(".getPokemonShapeByName(Id: int)", function() {
1296 | before(function() {
1297 | promise = secureP.getPokemonShapeByName(id);
1298 | });
1299 | it("should succeed", function() {
1300 | return promise;
1301 | });
1302 | it("should have property name", function() {
1303 | return expect(promise).to.eventually.have.property("name");
1304 | });
1305 | });
1306 |
1307 | describe(".getPokemonSpeciesByName(Id: int)", function() {
1308 | before(function() {
1309 | promise = secureP.getPokemonSpeciesByName(id);
1310 | });
1311 | it("should succeed", function() {
1312 | return promise;
1313 | });
1314 | it("should have property name", function() {
1315 | return expect(promise).to.eventually.have.property("name");
1316 | });
1317 | });
1318 |
1319 | describe(".getStatByName(Id: int)", function() {
1320 | before(function() {
1321 | promise = secureP.getStatByName(id);
1322 | });
1323 | it("should succeed", function() {
1324 | return promise;
1325 | });
1326 | it("should have property name", function() {
1327 | return expect(promise).to.eventually.have.property("name");
1328 | });
1329 | });
1330 |
1331 | describe(".getTypeByName(Id: int)", function() {
1332 | before(function() {
1333 | promise = secureP.getTypeByName(id);
1334 | });
1335 | it("should succeed", function() {
1336 | return promise;
1337 | });
1338 | it("should have property name", function() {
1339 | return expect(promise).to.eventually.have.property("name");
1340 | });
1341 | });
1342 |
1343 | describe(".getLanguageByName(Id: int)", function() {
1344 | before(function() {
1345 | promise = secureP.getLanguageByName(id);
1346 | });
1347 | it("should succeed", function() {
1348 | return promise;
1349 | });
1350 | it("should have property name", function() {
1351 | return expect(promise).to.eventually.have.property("name");
1352 | });
1353 | });
1354 |
1355 | describe(".getBerryByName(Name: string)", function() {
1356 | before(function() {
1357 | promise = secureP.getBerryByName('sfgfsgsfggsfg');
1358 | });
1359 | it("should fail", function() {
1360 | return expect(promise).rejected;
1361 | });
1362 | });
1363 |
1364 | });
1365 |
--------------------------------------------------------------------------------
/dist/index.js:
--------------------------------------------------------------------------------
1 | /*! For license information please see index.js.LICENSE.txt */
2 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Pokedex=t():e.Pokedex=t()}("undefined"!=typeof self?self:this,(()=>(()=>{var e={790:(e,t,n)=>{e.exports=function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};t[a][0].call(u.exports,(function(e){return o(t[a][1][e]||e)}),u,u.exports,e,t,n,r)}return n[a].exports}for(var i=void 0,a=0;a=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function b(e){var t=h[e.name],n={};n.promise=new a((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function w(e){var t=h[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function E(e,t){var n=h[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function S(e,t){return new a((function(n,r){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);b(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},n(t),w(e)}}))}function _(e){return S(e,!1)}function O(e){return S(e,!0)}function R(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.versione.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function A(e){return i([y(atob(e.data))],{type:e.type})}function T(e){return e&&e.__local_forage_encoded_blob}function N(e){var t=this,n=t._initReady().then((function(){var e=h[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return c(n,e,e),n}function I(e,t,n,r){void 0===r&&(r=1);try{var o=e.db.transaction(e.storeName,t);n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),O(e)})).then((function(){return function(e){b(e);for(var t=h[e.name],n=t.forages,r=0;r>4,f[c++]=(15&r)<<4|o>>2,f[c++]=(3&o)<<6|63&i;return u}function V(e){var t,n=new Uint8Array(e),r="";for(t=0;t>2],r+=C[(3&n[t])<<4|n[t+1]>>4],r+=C[(15&n[t+1])<<2|n[t+2]>>6],r+=C[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var K={serialize:function(e,t){var n="";if(e&&(n=$.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===$.call(e.buffer))){var r,o=P;e instanceof ArrayBuffer?(r=e,o+=x):(r=e.buffer,"[object Int8Array]"===n?o+=D:"[object Uint8Array]"===n?o+=L:"[object Uint8ClampedArray]"===n?o+=F:"[object Int16Array]"===n?o+=U:"[object Uint16Array]"===n?o+=q:"[object Int32Array]"===n?o+=M:"[object Uint32Array]"===n?o+=z:"[object Float32Array]"===n?o+=W:"[object Float64Array]"===n?o+=H:t(new Error("Failed to get type for BinaryArray"))),t(o+V(r))}else if("[object Blob]"===n){var i=new FileReader;i.onload=function(){var n="~~local_forage_type~"+e.type+"~"+V(this.result);t(P+B+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,9)!==P)return JSON.parse(e);var t,n=e.substring(13),r=e.substring(9,13);if(r===B&&k.test(n)){var o=n.match(k);t=o[1],n=n.substring(o[0].length)}var a=J(n);switch(r){case x:return a;case B:return i([a],{type:t});case D:return new Int8Array(a);case L:return new Uint8Array(a);case F:return new Uint8ClampedArray(a);case U:return new Int16Array(a);case q:return new Uint16Array(a);case M:return new Int32Array(a);case z:return new Uint32Array(a);case W:return new Float32Array(a);case H:return new Float64Array(a);default:throw new Error("Unkown type: "+r)}},stringToBuffer:J,bufferToString:V};function G(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function X(e,t,n,r,o,i){e.executeSql(n,r,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,s){s.rows.length?i(e,a):G(e,t,(function(){e.executeSql(n,r,o,i)}),i)}),i):i(e,a)}),i)}function Q(e,t,n,r){var o=this;e=u(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var s=t,c=o._dbInfo;c.serializer.serialize(t,(function(t,u){u?a(u):c.db.transaction((function(n){X(n,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(s)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void i(Q.apply(o,[e,s,n,r-1]));a(t)}}))}))})).catch(a)}));return s(i,n),i}var Y={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var o=new a((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(o){G(o,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=K,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){X(n,o,"SELECT * FROM "+o.storeName,[],(function(n,r){for(var i=r.rows,a=i.length,s=0;s '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var o=[],i=0;i0}var te={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=Z(e,this._defaultConfig),ee()?(this._dbInfo=t,t.serializer=K,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,s=0;s=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return s(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return s(t,e),t},key:function(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return s(r,t),r},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):a.reject("Invalid arguments"),s(r,t),r}},ne=function(e,t){for(var n=e.length,r=0;r{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{Pokedex:()=>Tt});var e={};n.r(e),n.d(e,{hasBrowserEnv:()=>ge,hasStandardBrowserEnv:()=>ve,hasStandardBrowserWebWorkerEnv:()=>be,navigator:()=>ye,origin:()=>we});var t=n(790),o=n.n(t);const i=JSON.parse('[["getBerry","name","berry/:id/"],["getBerryFirmness","name","berry-firmness/:id/"],["getBerryFlavor","name","berry-flavor/:id/"],["getContestType","name","contest-type/:id/"],["getContestEffect","id","contest-effect/:id/"],["getSuperContestEffect","id","super-contest-effect/:id/"],["getEncounterMethod","name","encounter-method/:id/"],["getEncounterCondition","name","encounter-condition/:id/"],["getEncounterConditionValue","name","encounter-condition-value/:id/"],["getEvolutionChain","id","evolution-chain/:id/"],["getEvolutionTrigger","name","evolution-trigger/:id/"],["getGeneration","name","generation/:id/"],["getPokedex","name","pokedex/:id/"],["getVersion","name","version/:id/"],["getVersionGroup","name","version-group/:id/"],["getItem","name","item/:id/"],["getItemAttribute","name","item-attribute/:id/"],["getItemCategory","name","item-category/:id/"],["getItemFlingEffect","name","item-fling-effect/:id/"],["getItemPocket","name","item-pocket/:id/"],["getMachine","id","machine/:id/"],["getMove","name","move/:id/"],["getMoveAilment","name","move-ailment/:id/"],["getMoveBattleStyle","name","move-battle-style/:id/"],["getMoveCategory","name","move-category/:id/"],["getMoveDamageClass","name","move-damage-class/:id/"],["getMoveLearnMethod","name","move-learn-method/:id/"],["getMoveTarget","name","move-target/:id/"],["getLocation","name","location/:id/"],["getLocationArea","name","location-area/:id/"],["getPalParkArea","name","pal-park-area/:id/"],["getRegion","name","region/:id/"],["getAbility","name","ability/:id/"],["getCharacteristic","id","characteristic/:id/"],["getEggGroup","name","egg-group/:id/"],["getGender","name","gender/:id/"],["getGrowthRate","name","growth-rate/:id/"],["getNature","name","nature/:id/"],["getPokeathlonStat","name","pokeathlon-stat/:id/"],["getPokemon","name","pokemon/:id/"],["getPokemonEncounterAreas","name","pokemon/:id/encounters/"],["getPokemonColor","name","pokemon-color/:id/"],["getPokemonForm","name","pokemon-form/:id/"],["getPokemonHabitat","name","pokemon-habitat/:id/"],["getPokemonShape","name","pokemon-shape/:id/"],["getPokemonSpecies","name","pokemon-species/:id/"],["getStat","name","stat/:id/"],["getType","name","type/:id/"],["getLanguage","name","language/:id/"]]'),a=JSON.parse('[["getEndpoints",""],["getBerries","berry/"],["getBerriesFirmnesss","berry-firmness/"],["getBerriesFlavors","berry-flavor/"],["getContestTypes","contest-type/"],["getContestEffects","contest-effect/"],["getSuperContestEffects","super-contest-effect/"],["getEncounterMethods","encounter-method/"],["getEncounterConditions","encounter-condition/"],["getEncounterConditionValues","encounter-condition-value/"],["getEvolutionChains","evolution-chain/"],["getEvolutionTriggers","evolution-trigger/"],["getGenerations","generation/"],["getPokedexs","pokedex/"],["getVersions","version/"],["getVersionGroups","version-group/"],["getItems","item/"],["getItemAttributes","item-attribute/"],["getItemCategories","item-category/"],["getItemFlingEffects","item-fling-effect/"],["getItemPockets","item-pocket/"],["getMachines","machine/"],["getMoves","move/"],["getMoveAilments","move-ailment/"],["getMoveBattleStyles","move-battle-style/"],["getMoveCategories","move-category/"],["getMoveDamageClasses","move-damage-class/"],["getMoveLearnMethods","move-learn-method/"],["getMoveTargets","move-target/"],["getLocations","location/"],["getLocationAreas","location-area/"],["getPalParkAreas","pal-park-area/"],["getRegions","region/"],["getAbilities","ability/"],["getCharacteristics","characteristic/"],["getEggGroups","egg-group/"],["getGenders","gender/"],["getGrowthRates","growth-rate/"],["getNatures","nature/"],["getPokeathlonStats","pokeathlon-stat/"],["getPokemons","pokemon/"],["getPokemonColors","pokemon-color/"],["getPokemonForms","pokemon-form/"],["getPokemonHabitats","pokemon-habitat/"],["getPokemonShapes","pokemon-shape/"],["getPokemonSpecies","pokemon-species/"],["getStats","stat/"],["getTypes","type/"],["getLanguages","language/"]]');function s(e,t){return function(){return e.apply(t,arguments)}}const{toString:c}=Object.prototype,{getPrototypeOf:u}=Object,f=(l=Object.create(null),e=>{const t=c.call(e);return l[t]||(l[t]=t.slice(8,-1).toLowerCase())});var l;const d=e=>(e=e.toLowerCase(),t=>f(t)===e),h=e=>t=>typeof t===e,{isArray:p}=Array,m=h("undefined"),g=d("ArrayBuffer"),y=h("string"),v=h("function"),b=h("number"),w=e=>null!==e&&"object"==typeof e,E=e=>{if("object"!==f(e))return!1;const t=u(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},S=d("Date"),_=d("File"),O=d("Blob"),R=d("FileList"),A=d("URLSearchParams"),[T,N,I,j]=["ReadableStream","Request","Response","Headers"].map(d);function C(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),p(e))for(r=0,o=e.length;r0;)if(r=n[o],t===r.toLowerCase())return r;return null}const P="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=e=>!m(e)&&e!==P,B=(D="undefined"!=typeof Uint8Array&&u(Uint8Array),e=>D&&e instanceof D);var D;const L=d("HTMLFormElement"),F=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),U=d("RegExp"),M=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};C(n,((n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)})),Object.defineProperties(e,r)},q="abcdefghijklmnopqrstuvwxyz",z="0123456789",W={DIGIT:z,ALPHA:q,ALPHA_DIGIT:q+q.toUpperCase()+z},H=d("AsyncFunction"),$=(J="function"==typeof setImmediate,V=v(P.postMessage),J?setImmediate:V?(K=`axios@${Math.random()}`,G=[],P.addEventListener("message",(({source:e,data:t})=>{e===P&&t===K&&G.length&&G.shift()()}),!1),e=>{G.push(e),P.postMessage(K,"*")}):e=>setTimeout(e));var J,V,K,G;const X="undefined"!=typeof queueMicrotask?queueMicrotask.bind(P):"undefined"!=typeof process&&process.nextTick||$,Q={isArray:p,isArrayBuffer:g,isBuffer:function(e){return null!==e&&!m(e)&&null!==e.constructor&&!m(e.constructor)&&v(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||v(e.append)&&("formdata"===(t=f(e))||"object"===t&&v(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&g(e.buffer),t},isString:y,isNumber:b,isBoolean:e=>!0===e||!1===e,isObject:w,isPlainObject:E,isReadableStream:T,isRequest:N,isResponse:I,isHeaders:j,isUndefined:m,isDate:S,isFile:_,isBlob:O,isRegExp:U,isFunction:v,isStream:e=>w(e)&&v(e.pipe),isURLSearchParams:A,isTypedArray:B,isFileList:R,forEach:C,merge:function e(){const{caseless:t}=x(this)&&this||{},n={},r=(r,o)=>{const i=t&&k(n,o)||o;E(n[i])&&E(r)?n[i]=e(n[i],r):E(r)?n[i]=e({},r):p(r)?n[i]=r.slice():n[i]=r};for(let e=0,t=arguments.length;e(C(t,((t,r)=>{n&&v(t)?e[r]=s(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let o,i,a;const s={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)a=o[i],r&&!r(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&u(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:f,kindOfTest:d,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(p(e))return e;let t=e.length;if(!b(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:L,hasOwnProperty:F,hasOwnProp:F,reduceDescriptors:M,freezeMethods:e=>{M(e,((t,n)=>{if(v(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];v(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return p(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:k,global:P,isContextDefined:x,ALPHABET:W,generateString:(e=16,t=W.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&v(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(w(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const o=p(e)?[]:{};return C(e,((e,t)=>{const i=n(e,r+1);!m(i)&&(o[t]=i)})),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:H,isThenable:e=>e&&(w(e)||v(e))&&v(e.then)&&v(e.catch),setImmediate:$,asap:X};function Y(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}Q.inherits(Y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Q.toJSONObject(this.config),code:this.code,status:this.status}}});const Z=Y.prototype,ee={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{ee[e]={value:e}})),Object.defineProperties(Y,ee),Object.defineProperty(Z,"isAxiosError",{value:!0}),Y.from=(e,t,n,r,o,i)=>{const a=Object.create(Z);return Q.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),Y.call(a,e.message,t,n,r,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};const te=Y;function ne(e){return Q.isPlainObject(e)||Q.isArray(e)}function re(e){return Q.endsWith(e,"[]")?e.slice(0,-2):e}function oe(e,t,n){return e?e.concat(t).map((function(e,t){return e=re(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const ie=Q.toFlatObject(Q,{},null,(function(e){return/^is[A-Z]/.test(e)})),ae=function(e,t,n){if(!Q.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Q.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Q.isUndefined(t[e])}))).metaTokens,o=n.visitor||u,i=n.dots,a=n.indexes,s=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Q.isSpecCompliantForm(t);if(!Q.isFunction(o))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Q.isDate(e))return e.toISOString();if(!s&&Q.isBlob(e))throw new te("Blob is not supported. Use a Buffer instead.");return Q.isArrayBuffer(e)||Q.isTypedArray(e)?s&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,n,o){let s=e;if(e&&!o&&"object"==typeof e)if(Q.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Q.isArray(e)&&function(e){return Q.isArray(e)&&!e.some(ne)}(e)||(Q.isFileList(e)||Q.endsWith(n,"[]"))&&(s=Q.toArray(e)))return n=re(n),s.forEach((function(e,r){!Q.isUndefined(e)&&null!==e&&t.append(!0===a?oe([n],r,i):null===a?n:n+"[]",c(e))})),!1;return!!ne(e)||(t.append(oe(o,n,i),c(e)),!1)}const f=[],l=Object.assign(ie,{defaultVisitor:u,convertValue:c,isVisitable:ne});if(!Q.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Q.isUndefined(n)){if(-1!==f.indexOf(n))throw Error("Circular reference detected in "+r.join("."));f.push(n),Q.forEach(n,(function(n,i){!0===(!(Q.isUndefined(n)||null===n)&&o.call(t,n,Q.isString(i)?i.trim():i,r,l))&&e(n,r?r.concat(i):[i])})),f.pop()}}(e),t};function se(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function ce(e,t){this._pairs=[],e&&ae(e,this,t)}const ue=ce.prototype;ue.append=function(e,t){this._pairs.push([e,t])},ue.toString=function(e){const t=e?function(t){return e.call(this,t,se)}:se;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};const fe=ce;function le(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function de(e,t,n){if(!t)return e;const r=n&&n.encode||le,o=n&&n.serialize;let i;if(i=o?o(t,n):Q.isURLSearchParams(t)?t.toString():new fe(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}const he=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Q.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},pe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},me={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:fe,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},ge="undefined"!=typeof window&&"undefined"!=typeof document,ye="object"==typeof navigator&&navigator||void 0,ve=ge&&(!ye||["ReactNative","NativeScript","NS"].indexOf(ye.product)<0),be="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,we=ge&&window.location.href||"http://localhost",Ee={...e,...me},Se=function(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const a=Number.isFinite(+i),s=o>=e.length;return i=!i&&Q.isArray(r)?r.length:i,s?(Q.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!a):(r[i]&&Q.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&Q.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r{t(function(e){return Q.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null},_e={transitional:pe,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=Q.isObject(e);if(o&&Q.isHTMLForm(e)&&(e=new FormData(e)),Q.isFormData(e))return r?JSON.stringify(Se(e)):e;if(Q.isArrayBuffer(e)||Q.isBuffer(e)||Q.isStream(e)||Q.isFile(e)||Q.isBlob(e)||Q.isReadableStream(e))return e;if(Q.isArrayBufferView(e))return e.buffer;if(Q.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ae(e,new Ee.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return Ee.isNode&&Q.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=Q.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return ae(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(Q.isString(e))try{return(0,JSON.parse)(e),Q.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||_e.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Q.isResponse(e)||Q.isReadableStream(e))return e;if(e&&Q.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw te.from(e,te.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ee.classes.FormData,Blob:Ee.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Q.forEach(["delete","get","head","post","put","patch"],(e=>{_e.headers[e]={}}));const Oe=_e,Re=Q.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ae=Symbol("internals");function Te(e){return e&&String(e).trim().toLowerCase()}function Ne(e){return!1===e||null==e?e:Q.isArray(e)?e.map(Ne):String(e)}function Ie(e,t,n,r,o){return Q.isFunction(r)?r.call(this,t,n):(o&&(t=n),Q.isString(t)?Q.isString(r)?-1!==t.indexOf(r):Q.isRegExp(r)?r.test(t):void 0:void 0)}class je{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Te(t);if(!o)throw new Error("header name must be a non-empty string");const i=Q.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Ne(e))}const i=(e,t)=>Q.forEach(e,((e,n)=>o(e,n,t)));if(Q.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(Q.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Re[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if(Q.isHeaders(e))for(const[t,r]of e.entries())o(r,t,n);else null!=e&&o(t,e,n);return this}get(e,t){if(e=Te(e)){const n=Q.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Q.isFunction(t))return t.call(this,e,n);if(Q.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Te(e)){const n=Q.findKey(this,e);return!(!n||void 0===this[n]||t&&!Ie(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Te(e)){const o=Q.findKey(n,e);!o||t&&!Ie(0,n[o],o,t)||(delete n[o],r=!0)}}return Q.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Ie(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return Q.forEach(this,((r,o)=>{const i=Q.findKey(n,o);if(i)return t[i]=Ne(r),void delete t[o];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(o):String(o).trim();a!==o&&delete t[o],t[a]=Ne(r),n[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Q.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Q.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Ae]=this[Ae]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Te(e);t[r]||(function(e,t){const n=Q.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return Q.isArray(e)?e.forEach(r):r(e),this}}je.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Q.reduceDescriptors(je.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),Q.freezeMethods(je);const Ce=je;function ke(e,t){const n=this||Oe,r=t||n,o=Ce.from(r.headers);let i=r.data;return Q.forEach(e,(function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function Pe(e){return!(!e||!e.__CANCEL__)}function xe(e,t,n){te.call(this,null==e?"canceled":e,te.ERR_CANCELED,t,n),this.name="CanceledError"}Q.inherits(xe,te,{__CANCEL__:!0});const Be=xe;function De(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new te("Request failed with status code "+n.status,[te.ERR_BAD_REQUEST,te.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}const Le=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,a=0;return t=void 0!==t?t:1e3,function(s){const c=Date.now(),u=r[a];o||(o=c),n[i]=s,r[i]=c;let f=a,l=0;for(;f!==i;)l+=n[f++],f%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o{o=i,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),s=t-o;s>=i?a(e,t):(n=e,r||(r=setTimeout((()=>{r=null,a(n)}),i-s)))},()=>n&&a(n)]}((n=>{const i=n.loaded,a=n.lengthComputable?n.total:void 0,s=i-r,c=o(s);r=i,e({loaded:i,total:a,progress:a?i/a:void 0,bytes:s,rate:c||void 0,estimated:c&&a&&i<=a?(a-i)/c:void 0,event:n,lengthComputable:null!=a,[t?"download":"upload"]:!0})}),n)},Fe=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ue=e=>(...t)=>Q.asap((()=>e(...t))),Me=Ee.hasStandardBrowserEnv?function(){const e=Ee.navigator&&/(msie|trident)/i.test(Ee.navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=Q.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0},qe=Ee.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const a=[e+"="+encodeURIComponent(t)];Q.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),Q.isString(r)&&a.push("path="+r),Q.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function ze(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const We=e=>e instanceof Ce?{...e}:e;function He(e,t){t=t||{};const n={};function r(e,t,n){return Q.isPlainObject(e)&&Q.isPlainObject(t)?Q.merge.call({caseless:n},e,t):Q.isPlainObject(t)?Q.merge({},t):Q.isArray(t)?t.slice():t}function o(e,t,n){return Q.isUndefined(t)?Q.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function i(e,t){if(!Q.isUndefined(t))return r(void 0,t)}function a(e,t){return Q.isUndefined(t)?Q.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function s(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const c={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:(e,t)=>o(We(e),We(t),!0)};return Q.forEach(Object.keys(Object.assign({},e,t)),(function(r){const i=c[r]||o,a=i(e[r],t[r],r);Q.isUndefined(a)&&i!==s||(n[r]=a)})),n}const $e=e=>{const t=He({},e);let n,{data:r,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:a,headers:s,auth:c}=t;if(t.headers=s=Ce.from(s),t.url=de(ze(t.baseURL,t.url),e.params,e.paramsSerializer),c&&s.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Q.isFormData(r))if(Ee.hasStandardBrowserEnv||Ee.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(!1!==(n=s.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];s.setContentType([e||"multipart/form-data",...t].join("; "))}if(Ee.hasStandardBrowserEnv&&(o&&Q.isFunction(o)&&(o=o(t)),o||!1!==o&&Me(t.url))){const e=i&&a&&qe.read(a);e&&s.set(i,e)}return t},Je="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=$e(e);let o=r.data;const i=Ce.from(r.headers).normalize();let a,s,c,u,f,{responseType:l,onUploadProgress:d,onDownloadProgress:h}=r;function p(){u&&u(),f&&f(),r.cancelToken&&r.cancelToken.unsubscribe(a),r.signal&&r.signal.removeEventListener("abort",a)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Ce.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());De((function(e){t(e),p()}),(function(e){n(e),p()}),{data:l&&"text"!==l&&"json"!==l?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new te("Request aborted",te.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new te("Network Error",te.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const o=r.transitional||pe;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new te(t,o.clarifyTimeoutError?te.ETIMEDOUT:te.ECONNABORTED,e,m)),m=null},void 0===o&&i.setContentType(null),"setRequestHeader"in m&&Q.forEach(i.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),Q.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),l&&"json"!==l&&(m.responseType=r.responseType),h&&([c,f]=Le(h,!0),m.addEventListener("progress",c)),d&&m.upload&&([s,u]=Le(d),m.upload.addEventListener("progress",s),m.upload.addEventListener("loadend",u)),(r.cancelToken||r.signal)&&(a=t=>{m&&(n(!t||t.type?new Be(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(a),r.signal&&(r.signal.aborted?a():r.signal.addEventListener("abort",a)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);y&&-1===Ee.protocols.indexOf(y)?n(new te("Unsupported protocol "+y+":",te.ERR_BAD_REQUEST,e)):m.send(o||null)}))},Ve=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const o=function(e){if(!n){n=!0,a();const t=e instanceof Error?e:this.reason;r.abort(t instanceof te?t:new Be(t instanceof Error?t.message:t))}};let i=t&&setTimeout((()=>{i=null,o(new te(`timeout ${t} of ms exceeded`,te.ETIMEDOUT))}),t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(o):e.removeEventListener("abort",o)})),e=null)};e.forEach((e=>e.addEventListener("abort",o)));const{signal:s}=r;return s.unsubscribe=()=>Q.asap(a),s}},Ke=function*(e,t){let n=e.byteLength;if(!t||n{const o=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Ke(n,t)}(e,t);let i,a=0,s=e=>{i||(i=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await o.next();if(t)return s(),void e.close();let i=r.byteLength;if(n){let e=a+=i;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel:e=>(s(e),o.return())},{highWaterMark:2})},Xe="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Qe=Xe&&"function"==typeof ReadableStream,Ye=Xe&&("function"==typeof TextEncoder?(Ze=new TextEncoder,e=>Ze.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ze;const et=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},tt=Qe&&et((()=>{let e=!1;const t=new Request(Ee.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),nt=Qe&&et((()=>Q.isReadableStream(new Response("").body))),rt={stream:nt&&(e=>e.body)};var ot;Xe&&(ot=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!rt[e]&&(rt[e]=Q.isFunction(ot[e])?t=>t[e]():(t,n)=>{throw new te(`Response type '${e}' is not supported`,te.ERR_NOT_SUPPORT,n)})})));const it={http:null,xhr:Je,fetch:Xe&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:i,timeout:a,onDownloadProgress:s,onUploadProgress:c,responseType:u,headers:f,withCredentials:l="same-origin",fetchOptions:d}=$e(e);u=u?(u+"").toLowerCase():"text";let h,p=Ve([o,i&&i.toAbortSignal()],a);const m=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let g;try{if(c&&tt&&"get"!==n&&"head"!==n&&0!==(g=await(async(e,t)=>{const n=Q.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Q.isBlob(e))return e.size;if(Q.isSpecCompliantForm(e)){const t=new Request(Ee.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Q.isArrayBufferView(e)||Q.isArrayBuffer(e)?e.byteLength:(Q.isURLSearchParams(e)&&(e+=""),Q.isString(e)?(await Ye(e)).byteLength:void 0)})(t):n})(f,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(Q.isFormData(r)&&(e=n.headers.get("content-type"))&&f.setContentType(e),n.body){const[e,t]=Fe(g,Le(Ue(c)));r=Ge(n.body,65536,e,t)}}Q.isString(l)||(l=l?"include":"omit");const o="credentials"in Request.prototype;h=new Request(t,{...d,signal:p,method:n.toUpperCase(),headers:f.normalize().toJSON(),body:r,duplex:"half",credentials:o?l:void 0});let i=await fetch(h);const a=nt&&("stream"===u||"response"===u);if(nt&&(s||a&&m)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=i[t]}));const t=Q.toFiniteNumber(i.headers.get("content-length")),[n,r]=s&&Fe(t,Le(Ue(s),!0))||[];i=new Response(Ge(i.body,65536,n,(()=>{r&&r(),m&&m()})),e)}u=u||"text";let y=await rt[Q.findKey(rt,u)||"text"](i,e);return!a&&m&&m(),await new Promise(((t,n)=>{De(t,n,{data:y,headers:Ce.from(i.headers),status:i.status,statusText:i.statusText,config:e,request:h})}))}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new te("Network Error",te.ERR_NETWORK,e,h),{cause:t.cause||t});throw te.from(t,t&&t.code,e,h)}})};Q.forEach(it,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const at=e=>`- ${e}`,st=e=>Q.isFunction(e)||null===e||!1===e,ct=e=>{e=Q.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));let n=t?e.length>1?"since :\n"+e.map(at).join("\n"):" "+at(e[0]):"as no adapter specified";throw new te("There is no suitable adapter to dispatch the request "+n,"ERR_NOT_SUPPORT")}return r};function ut(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Be(null,e)}function ft(e){return ut(e),e.headers=Ce.from(e.headers),e.data=ke.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ct(e.adapter||Oe.adapter)(e).then((function(t){return ut(e),t.data=ke.call(e,e.transformResponse,t),t.headers=Ce.from(t.headers),t}),(function(t){return Pe(t)||(ut(e),t&&t.response&&(t.response.data=ke.call(e,e.transformResponse,t.response),t.response.headers=Ce.from(t.response.headers))),Promise.reject(t)}))}const lt={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{lt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const dt={};lt.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.7] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new te(r(o," has been removed"+(t?" in "+t:"")),te.ERR_DEPRECATED);return t&&!dt[o]&&(dt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}};const ht={assertOptions:function(e,t,n){if("object"!=typeof e)throw new te("options must be an object",te.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],a=t[i];if(a){const t=e[i],n=void 0===t||a(t,i,e);if(!0!==n)throw new te("option "+i+" must be "+n,te.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new te("Unknown option "+i,te.ERR_BAD_OPTION)}},validators:lt},pt=ht.validators;class mt{constructor(e){this.defaults=e,this.interceptors={request:new he,response:new he}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=He(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&ht.assertOptions(n,{silentJSONParsing:pt.transitional(pt.boolean),forcedJSONParsing:pt.transitional(pt.boolean),clarifyTimeoutError:pt.transitional(pt.boolean)},!1),null!=r&&(Q.isFunction(r)?t.paramsSerializer={serialize:r}:ht.assertOptions(r,{encode:pt.function,serialize:pt.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&Q.merge(o.common,o[t.method]);o&&Q.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=Ce.concat(i,o);const a=[];let s=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(s=s&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));const c=[];let u;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let f,l=0;if(!s){const e=[ft.bind(this),void 0];for(e.unshift.apply(e,a),e.push.apply(e,c),f=e.length,u=Promise.resolve(t);l{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,o){n.reason||(n.reason=new Be(e,r,o),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new yt((function(t){e=t})),cancel:e}}}const vt=yt,bt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(bt).forEach((([e,t])=>{bt[t]=e}));const wt=bt,Et=function e(t){const n=new gt(t),r=s(gt.prototype.request,n);return Q.extend(r,gt.prototype,n,{allOwnKeys:!0}),Q.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(He(t,n))},r}(Oe);Et.Axios=gt,Et.CanceledError=Be,Et.CancelToken=vt,Et.isCancel=Pe,Et.VERSION="1.7.7",Et.toFormData=ae,Et.AxiosError=te,Et.Cancel=Et.CanceledError,Et.all=function(e){return Promise.all(e)},Et.spread=function(e){return function(t){return e.apply(null,t)}},Et.isAxiosError=function(e){return Q.isObject(e)&&!0===e.isAxiosError},Et.mergeConfig=He,Et.AxiosHeaders=Ce,Et.formToJSON=e=>Se(Q.isHTMLForm(e)?new FormData(e):e),Et.getAdapter=ct,Et.HttpStatusCode=wt,Et.default=Et;const St=Et,_t="pokeapi-js-wrapper-";function Ot(e,t){return new Promise(((n,r)=>{o().ready().then((()=>{o().getItem(`${_t}${t}`).then((o=>{null===o?Rt(e,t).then((e=>{n(e)})).catch((e=>{r(e)})):n(addCacheMark(o))})).catch((o=>{Rt(e,t).then((e=>{n(e)})).catch((e=>{r(e)}))}))})).catch((o=>{Rt(e,t).then((e=>{n(e)})).catch((e=>{r(e)}))}))}))}function Rt(e,t){return new Promise(((n,r)=>{let i={baseURL:`${e.protocol}://${e.hostName}/`,timeout:e.timeout};St.get(t,i).then((i=>{i.status>=400?r(i):(e.cache&&o().setItem(`${_t}${t}`,i.data),n(i.data))})).catch((e=>{r(e)}))}))}class At{constructor(e={}){this.protocol="https",this.hostName="pokeapi.co",this.versionPath="/api/v2/",this.offset=0,this.limit=1e5,this.timeout=1e4,this.cache=!0,this.cacheImages=!1,e.hasOwnProperty("protocol")&&(this.protocol=e.protocol),e.hasOwnProperty("hostName")&&(this.hostName=e.hostName),e.hasOwnProperty("versionPath")&&(this.versionPath=e.versionPath),e.hasOwnProperty("offset")&&(this.offset=e.offset-1),e.hasOwnProperty("limit")&&(this.limit=e.limit),e.hasOwnProperty("timeout")&&(this.timeout=e.timeout),e.hasOwnProperty("cache")&&(this.cache=e.cache),e.hasOwnProperty("cacheImages")&&(this.cacheImages=e.cacheImages)}}o().config({name:"pokeapi-js-wrapper"});class Tt{constructor(e){this.config=new At(e),i.forEach((e=>{const t=function(e){return`${e[0]}By${function([e,...t]){return e.toUpperCase()+t.join("").toLowerCase()}(e[1])}`}(e);this[t]=t=>{if(t){if("number"==typeof t||"string"==typeof t)return Ot(this.config,`${this.config.versionPath}${e[2].replace(":id",t)}`);if("object"==typeof t)return Promise.all(function(e,t,n){return n.map((n=>Ot(e,`${e.versionPath}${t[2].replace(":id",n)}`)))}(this.config,e,t))}},this[function(e){return`${e[0]}`}(e)]=this[t]})),a.forEach((e=>{const t=`${e[0]}List`;this[t]=t=>{var n=this.config.limit,r=this.config.offset;return t&&(t.hasOwnProperty("offset")&&(r=t.offset),t.hasOwnProperty("limit")&&(n=t.limit)),Ot(this.config,`${this.config.versionPath}${e[1]}?limit=${n}&offset=${r}`)},this[e[0]]=this[t]})),this.config.cacheImages&&navigator&&window&&"serviceWorker"in navigator&&window.addEventListener("load",(function(){navigator.serviceWorker.register("./pokeapi-js-wrapper-sw.js",{scope:"./"}).catch((e=>{console.log("Pokeapi-js-wrapper SW installation failed with the following error:"),console.error(e)}))}))}getConfig(){return this.config}getCacheLength(){return o().length()}clearCache(){return o().clear()}resource(e){return"string"==typeof e?Ot(this.config,e):Array.isArray(e)?Promise.all(e.map((e=>Ot(this.config,e)))):"String or Array is required"}}})(),r})()));
3 | //# sourceMappingURL=index.js.map
--------------------------------------------------------------------------------