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

pokemon3d-image-resolver

v1.13.3

Published

A package to fetch Pokémon images in GIF format, supporting 3D, front-facing, back-facing, and shiny variants.

Downloads

25

Readme

🚀 Pokemon Image Resolver 🚀

🌐 Langue

Les noms des Pokémon utilisés dans ce package sont en anglais.

🖼️ Exemple des résultats

Voici un exemple des résultats pour les versions front-normal, front-shiny, back-normal et back-shiny de Aerodactyl :

📦 Installation

npm install pokemon3d-image-resolver

🛠 Utilisation

Récupérer une image spécifique

  1. Importez les fonctions et types nécessaires :
import { getPokemon, PokemonData } from "pokemon3d-image-resolver";
  1. Définissez les paramètres :
const myPokemon: PokemonData = {
  name: "pikachu",
  version: "front-shiny",
};
  1. Récupérez l'image :
const imageData = await getPokemon(myPokemon);
if (imageData) {
  console.log("Votre image Pokemon en base64 :", imageData);
} else {
  console.log("Image Pokemon introuvable.");
}

Récupérer toutes les versions d'un Pokemon

import { getAllPokemonVersions } from "pokemon3d-image-resolver";

const pikachuImages = await getAllPokemonVersions("pikachu");
console.log(pikachuImages["front-shiny"]); // Ceci affichera l'image "front-shiny" de Pikachu en base64, ou `null` si elle n'est pas trouvée.

🖼️ Utilisation de la chaîne base64 dans une balise img

Une fois que vous avez récupéré la chaîne base64 de l'image de votre Pokémon, vous pouvez l'utiliser directement dans une balise img de votre HTML :

<img src="data:image/gif;base64,CHAINE_BASE64_ICI" alt="Pokemon Image" />

En utilisant le code JavaScript ou autres, cela donnerait :

const base64Image = await getPokemon({
  name: "pikachu",
  version: "front-shiny",
});
const imgElement = `<img src="${base64Image}" alt="Image de Pikachu" />`;

🔍 Versions disponibles

  • front-normal : Image standard de face
  • back-normal : Image standard de dos
  • front-shiny : Image shiny de face
  • back-shiny : Image shiny de dos

❓ Problèmes ou suggestions

Si vous rencontrez des problèmes ou avez des suggestions, n'hésitez pas à ouvrir un ticket.

Exemple de code et d'utilisation sur Express, pour vous aider.

nom init -y
npm install express
npm install pokemon3d-image-resolver
const {
  getPokemon,
  getAllPokemonVersions,
} = require("pokemon3d-image-resolver");
const express = require("express");
const app = express();
const PORT = 3000;

// ==== Appelez getAllPokemonVersions avec le name du pokemon provenant de l'URL ==== \\
app.get("/getAll/:name", async (req, res) => {
  const { name } = req.params;

  try {
    const versions = await getAllPokemonVersions(name);

    res.write("<h1>Versions de Pokemon</h1>");
    for (const version in versions) {
      if (versions[version]) {
        res.write(`<h2>${version}</h2>`);
        res.write(`<img src="${versions[version]}" alt="${version}" />`);
      }
    }

    res.end();
  } catch (error) {
    console.error(`Failed to get versions for ${name}:`, error);
    res.status(500).send("Internal server error");
  }
});

// ==== Appelez getPokemon avec le name du pokemon provenant de l'URL ==== \\
app.get("/:name", async (req, res) => {
  const { name } = req.params;

  try {
    const pokemon = await getPokemon({ name: name, version: "front-normal" }); // Utilisation du paramètre "name" plutôt que "Pikachu" en dur.

    res.write("<h1>Pokemon</h1>");
    res.write(`<h2>${name}</h2>`);
    if (pokemon) {
      res.write(`<img src="${pokemon}" alt="${name}" />`);
    } else {
      res.write(`<p>Image non trouvée pour ${name}.</p>`);
    }

    res.end();
  } catch (error) {
    console.error(`Failed to get image for ${name}:`, error);
    res.status(500).send("Internal server error");
  }
});

📝 Licence

ISC