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

select-potter-character

v1.0.8

Published

This Harry Potter Character Filter is an easy-to-use JavaScript package that interacts with the Harry Potter API to filter characters based on specific criteria. This package allows you to search for characters by gender, species, house and wizard status,

Downloads

5

Readme

02 – Architecture open source

This Harry Potter Character Filter is an easy-to-use JavaScript package that interacts with the Harry Potter API to filter characters based on specific criteria. This package allows you to search for characters by gender, species, house and wizard status, and returns a random character that matches the given criteria.

Prerequisites

Installation

npm i select-potter-character

Local development

npm install
npm run test

Features

  • Random Harry Potter Character retrieval: Uses the HP-API to fetch random Character.
  • Ability to filter characters by 4 different criteria : Gender ( male, female), Species ( human, werewolf, dog ...), House () or wizard ( true of false )
  • Each filter is case insensitive ( everything's transformed to lowercase )

Project Structure

02–Architecture/
├── index.js
├── index.test.js
├── babel.config.cjs
├── package.json
├── README.md
├── LICENSE

Get a random character

Retrieve a character randomly from the Harry Potter world

import { getHarryPotterCharacter } from "select-potter-character";

console.log(await getHarryPotterCharacter());

return an object with all attributes of the randomly selected Harry Potter character

Get a character based on gender

Retrieve a character randomly from the Harry Potter world with the provided gender

  • male
  • female
import { getHarryPotterCharacter } from "select-potter-character";

console.log(await getHarryPotterCharacter({ gender: "male" }));

return an object with

  • an error, set to true if the API call failed - false otherwise
  • a message to help understand the response in case an error occurred or not character matching provided criteria was found
  • a data key containing the randomly selected character if any

Get a character based on species

Retrieve a character randomly from the Harry Potter world with the provided species

  • human
  • half-human
  • goblin
  • werewolf
  • giant
  • half-giant
  • house-elf
  • hat
  • dog
  • cat
  • owl
  • pygmy puff
  • toad
  • snake
  • serpent
  • acromantula
  • hippogriff
  • phoenix
  • three-headed dog
  • dragon
  • centaur
  • vampire
  • cephalopod
  • selkie
  • ghost
  • poltergeist
import { getHarryPotterCharacter } from "select-potter-character";

console.log(await getHarryPotterCharacter({ species: "werewolf" }));

return an object with

  • an error, set to true if the API call failed - false otherwise
  • a message to help understand the response in case an error occurred or not character matching provided criteria was found
  • a data key containing the randomly selected character if any

Get a character based on house

Retrieve a character randomly from the Harry Potter world from the provided house

  • Gryffindor
  • Slytherin
  • Hufflepuff
  • Ravenclaw
import { getHarryPotterCharacter } from "select-potter-character";

console.log(await getHarryPotterCharacter({ house: "Gryffindor" }));

return an object with

  • an error, set to true if the API call failed - false otherwise
  • a message to help understand the response in case an error occurred or not character matching provided criteria was found
  • a data key containing the randomly selected character if any

Get a character based on being a wizard

Retrieve a character randomly from the Harry Potter world based on whether he/she is a wizard

import { getHarryPotterCharacter } from "select-potter-character";

console.log(await getHarryPotterCharacter({ wizard: true }));

return an object with

  • an error, set to true if the API call failed - false otherwise
  • a message to help understand the response in case an error occurred or not character matching provided criteria was found
  • a data key containing the randomly selected character if any

Get a character based on a combination of above criteria

Retrieve a character randomly from the Harry Potter world with a combination of any of the above filtering criteria

import { getHarryPotterCharacter } from "select-potter-character";

console.log(
  await getHarryPotterCharacter({ gender: "male", species: "human" })
);

return an object with

  • an error, set to true if the API call failed - false otherwise
  • a message to help understand the response in case an error occurred or not character matching provided criteria was found
  • a data key containing the randomly selected character if any

License

Distributed under the MIT License. See LICENSE for more information.