Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/numminorihsf/json-pokemon
Package with pokemons
https://github.com/numminorihsf/json-pokemon
pokemon
Last synced: 13 days ago
JSON representation
Package with pokemons
- Host: GitHub
- URL: https://github.com/numminorihsf/json-pokemon
- Owner: NumminorihSF
- License: mit
- Created: 2019-01-18T02:32:10.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-18T02:50:07.000Z (almost 6 years ago)
- Last Synced: 2024-10-04T19:43:28.541Z (about 1 month ago)
- Topics: pokemon
- Language: JavaScript
- Size: 11.7 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-pokemon
This package includes list of all pokemons. Original data is available on .
## Install
To install this package use
```bash
npm install --save json-pokemon
```## Usage
`require` command just returns a list of pokemon objects. The format is next:
```js
const pokemons = require('json-pokemon');const pokemon = pokemons[0];
// pokemon's structure:
// {
// id: 1,
// name: 'some-pokemon-name',
// typeList: ['Fire', 'Grass']
// }
```## Possible usage
```js
const getPokemons = require('json-pokemon/getPokemon');const pokemons = getPokemons(); // See API in the next section.
const firstPokemon = getPokemons.getPokemonById(1); // See API in the next section.
const snow = getPokemons.getPokemonByName('snow'); // See API in the next section.
```## API
#### Table of Contents
- [Pokemon](#pokemon)
- [Properties](#properties)
- [getPokemonById](#getpokemonbyid)
- [Parameters](#parameters)
- [getPokemonByName](#getpokemonbyname)
- [Parameters](#parameters-1)
- [getPokemon](#getpokemon)
- [Parameters](#parameters-2)### Pokemon
Pokemon's type.
Type: [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
#### Properties
- `id` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Pokemon's id.
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Pokemon's name.
- `typeList` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** Pokemon's types.### getPokemonById
Returns pokemon found by its id.
#### Parameters
- `id` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Pokemon's id.
Returns **([Pokemon](#pokemon) | null)** Pokemon if founded, else returns null.
### getPokemonByName
Returns pokemon found by its name.
#### Parameters
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Pokemon's id.
Returns **([Pokemon](#pokemon) | null)** Pokemon if founded, else returns null.
### getPokemon
Returns list of pokemons filtered with passed info.
#### Parameters
- `filter` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Filter descriptor. (optional, default `{}`)
- `filter.type` **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null)** Types of pokemons to returns.
If type is `null`, skip this filter. If type is string, returns list of pokemons which has this type.
If type is an array, returns list of pokemons which has all of types. (optional, default `null`)Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Pokemon](#pokemon)>** List of filtered pokemons.