npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@erezushi/pokemon-randomizer

v1.14.0

Published

Library to pick random teams of Pokémon, updated to Scarlet & Violet

Downloads

361

Readme

Pokémon Randomizer - By Dylan Stankievech

Try @erezushi/pokemon-randomizer on RunKit NPM npm bundle size (scoped) Libraries.io dependency status for latest release

Edits by Erez Bracha, original library here

This is a simple library to generate random teams of Pokémon.

For an interactive UI based on this package, click here

Table of Contents:

Options

| Option | Type | Description | Default | Notes | |:---:|:---:|:---:|:---:|:---:| | number | number | Number of random Pokémon to generate | 6 | integer > 0 | | baby | boolean | Choose only baby Pokémon (species released in a later generation than their evolutions) | false | | | basic | boolean | Choose only basic Pokémon (lowest evolution stage excluding babies) | false | | | evolved | boolean | Choose only fully evolved Pokémon | false | | | type | string | Choose only Pokémon of this type | - | enter a single type's name in lowercase | | randomType | boolean | Choose only Pokémon of a random type | false | | | superEffective | string | Choose only Pokémon super effective against this type | - | enter a single type's name in lowercase | | unique | boolean | Choose no duplicate Pokémon | false | | | starter | boolean | Choose only Pokémon from the starter lines | false | | | legendary | boolean | Choose only Legendary and Mythical Pokémon (Legendary can be a controversial term) | false | | | mythical | boolean | Choose only Mythical Pokémon | false | | | forms | boolean | Include alternate forms of Pokémon in the results | false | | | generations | string[] | Choose Pokémon only from the specified generations | - | Example: ['1', '2', '4', '6'] | | customList | string[] | Specify names of Pokémon to choose from | - | Pokémon names must match internal names in all but case. Internal list can be obtained using the exported getPokemon function for increased ease.

Please note that some options are supposed to be mutually exclusive:

  • Setting baby to true together with either basic and/or evolved would return no results
  • Setting starter to true together with either legendary and/or mythical would return no results
  • Setting both legendary and mythical to true is the same as just setting mythical to true
  • randomType option will be ignored if you've set the type option
  • Setting the customList option will cause all options except number, unique and forms to be ignored

return to top

Returned Fields

  • name: The name of the Pokémon.
  • type: The type[s] of the Pokémon.
  • dexNo: The national Pokédex number of the Pokémon.
  • evolveTo: The national Pokédex number[s] of the Pokémon this Pokémon evolves to (where applicable).
  • starter: states that this Pokémon is a starter (will wither be true or won't exist).
  • legendary: states that this Pokémon is a legendary Pokémon (will wither be true or won't exist).
  • mythical: states that this Pokémon is a mythical Pokémon (will wither be true or won't exist).
  • basic: states that this Pokémon is a basic stage Pokémon (will wither be true or won't exist).
  • forms: an object array with different forms of the Pokémon (where applicable). Form object contains the fields name, type and evolveTo (function the same as these fields above).

return to top

Non-Default Exports

  • TypeScript types (all types used in the library are exported):
    • PokemonType: String enum of all 18 types.
    • SpecieType: String enum of all possible typings a Pokémon specie can have.
    • Form: The type of the values in the forms field of the Pokémon list.
    • ListPokemon: Object detailing a Pokémon species (Returned Fields without dexNo).
    • Pokemon: The type of the values in the main function's result array.
    • PokemonMap: Record<string, ListPokemon> - The type of the internal Pokémon List.
    • TypeMatchups: Object detailing type matchups of a specific type.
    • TypeMap: Record<PokemonType, TypeMatchups> - The type of the internal type list.
    • Options: Type of the only parameter of the main function.
    • Generation: Object detailing the first and last indices of a generation.
    • GenerationMap: Record<string, Generation> - The type of the internal generation list.
  • Extra functions:
    • getPokemon: () => PokemonMap - Returns the internal Pokémon list
    • getTypes: () => TypeMap - Returns the internal type list
    • getGenerations: () => GenerationMap - Returns the internal Generation list

return to top

Examples

import RandomPokemon from '@erezushi/pokemon-randomizer';

// No options - Chooses 6 random Pokémon
const result = RandomPokemon();
// result = [
//     { name: 'Pikachu', ... },
//     { name: 'Mewtwo', ... },
//     ...
// ]

// Chooses 3 random, unique, final stage Pokémon, that are super effective against fire
const fullyEvolved = RandomPokemon({
    number: 3,
    unique: true,
    evolved: true,
    superEffective: 'fire'
});
// fullyEvolved = [
//     { name: 'Blastoise', ... },
//     { name: 'Golem', ... },
//     { name: 'Omastar', ...},
// ]

// Using the customList option
const customList = [
    "charmander",
    "vulpix",
    "eevee",
    "latias",
    "zorua",
    "fennekin",
    "litten",
    "sprigatito",
];

const customFilter = RandomPokemon({
    number: 3,
    unique: true,
    customList,
});
// CustomFilter = [
//     { name: 'Fennekin' ... },
//     { name: 'Vulpix' ... },
//     { name: 'Latias' ... },
// ]

return to top