Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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.