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

dnd_api_helper

v2.8.1

Published

``` npm i dnd_api_helper ``` This module sends several requests to an [dnd5e api](http://www.dnd5eapi.co/docs/#overview). The reason this module exists is to provide a simplified interface for developers to interact with chosen parts of the mentioned api.

Downloads

36

Readme

DND api helper module

npm i dnd_api_helper

This module sends several requests to an dnd5e api. The reason this module exists is to provide a simplified interface for developers to interact with chosen parts of the mentioned api. It is not meant to replace the already existing api unless the developer using this module is planning on creating a super simple dnd application.

Demo application

The demo application is restricted to people cloning the repo from github to decrease bundle size on npm, it can be launched by

  • Cloning this repo to your local machine
  • Running npm install followed by npm run demo

The demo application will automatically be updated as new classes are added to the exports of src/index.js and is not meant to be used as a source of truth but simply to show what kind of data you can expect from the different function calls.

Example usage

import { EncounterCreator } from 'dnd_api_helper'

const encounterCreator = new EncounterCreator()

const monsters = await encounterCreator.getRandomMonsters(3)

console.log(monsters)

Classes

Not all classes are available to use with installed module

    classDiagram
        CRUDService <|-- MonsterService
        CRUDService <|-- ClassService
        CRUDService <|-- RaceService
        CRUDService <|-- SpellService

        MonsterService"1"<--EncounterCreator
        SpellService"1"<--CharacterCreator
        RaceService"1"<--CharacterCreator
        ClassService"1"<--CharacterCreator
        CharacterCreator-->Character


        class CRUDService{
            <<abstract>>
            +String url
            +getAll()
            +getOne()
            +getRandom()
        }

        class Character{
            -character
            +race
            +class
            +spells
            +proficiencies
            +subclass
            +features
            +getCharacter()
        }

        class Die{
            -sides
            -value
            +Dice(sides)
            +isValidSides(sides)
            +roll()
            +rollMultipleTimes(times)
            +toString()
            +toJSON()
        }

        class SpellService{
            +getClassSpells(classIndex)
        }

        class EncounterCreator{
            +getRandomMonsters(numberOfMonsters, challengeRating)
        }

        class CharacterCreator{
            +getRandomCharacter()
            +getRandomSpells(numberOfSpells)
            +getRandomFeatures(numberOfFeatures)
        }

EncounterCreator

getRandomMonsters(@Optional numberOfMonsters: number, @Optional challengeRating: number). This method fetches all monsters with the desired challenge rating(if any has been specified) and picks one or more random monsters from the retrieved list.

CharacterCreator

getRandomCharacter(). This method uses the different services to fetch random classes, races and so on to build a random character. This method is meant to be used as a simple way to quickly create npcs etc.

Die

User to emulate a die

MonsterService, ClassService, RaceService, SpellService

All of these classes are wrapper functions to simplify work with the dnd api.

Example usage

const monsterService = new MonsterService();

cosnt monsters = await monsterService.getAll()

console.log(monsters)

const specificMonster = await monsterService.getOne(monsters.results[0].index)

console.log(specificMonster)

getAll(). This method fetches all available entries depending on service type. getOne(index). Fetches one specific entry.

Testing

Unittesting is done using Jest and is a work in progess.

npm test

NPM

Information about the current version can be found on npm.