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

ne-rpg-tools

v1.1.0

Published

Nyteshade Enterprises Pen and Paper RPG Tools

Downloads

5

Readme

ne-rpg-tools

Nyteshade Enterprises - RPG Tools

Introduction

A combination of tools for working with pen and paper role-playing games. The process for this repo started a long time ago and has culminated in some new refined tools for rolling virtual dice and choosing elements from life path style lists in a controlled and programmatic environment.

Features

Weighted Randoms

At the core of ne-rpg-tools is the weighted random. Most of the other tools have been developed around this feature set. Weighted Randoms allow you to setup a set of potential options and choose from them randomly. As the name implies, however, certain values can be setup to have a higher priority than others.

The library itself has been tailored to be efficient. Some folks might indicate that an array with two 1s and four 2s would allow for twice the opportunity of a two being chosen over a one. Technically this is true but the implementation is both sloppy and wasteful. It is also difficult to setup and cumbersome to manage.

Weighted Randoms solve this problem by assigning each element in the list a weight. The items appear only once. The weight of each entry is tallied up and a random number is chosen from 0 to the total weight of all items. Then the list of items is walked and their weights added until the randomly chosen value is within the range of the weight of the currently chosen item.

So if the list consists of values one through five and each item has a weight of one hundred. A random number from 0 to 500, not including 500, is chosen. If 233.5 is selected, then the value in the list would be the number 3.

functionOrValue

Many times, especially with a list of undetermined objects, we might want to substitute a value with a function that returns that value. This method will take a given JavaScript value and if the object is a function, then return the results of its execution. Otherwise, the object is passed back the same as it was received.

createMutableEnum, createEnum

Enums are a feature provided by other programming languages but mostly eschewed by JavaScript. Their usage, however, provides a powerful way of handling constant values. These functions provide a way to define some of these enums easily and effectively. There are two functions exported; one creates read only enum objects and the other creates readable and writable enums. Each enum has a constant variable name that maps to a number. The resulting number maps back to the variable name as a String. Additionally, each element in the enum can have a separately stored description and an additional set of data. The description and data are stored using Symbols