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

shesha

v0.0.11

Published

Random generator tools

Downloads

8

Readme

Shesha

Shesha, King of the Nagas

A tool for quickly building random generators. (Still pretty rough, but working.)

Command Line Quickstart

For the command line interface, do this:

npm install -g shesha
shesha "Shesha is [!c /cool/nice/great/sssuper/]!"

If you're intrigued, read on...

Web Version

Even if you want to use Shesha mainly on the command line, it's easier to play around with the commands at first in the web version.

To use the web version, go here or check out the git repo and start an HTTP server.

The left pane is code, and after every keypress the right pane is updated.

The code in the left pane is divided into blocks separated by blank lines. There are three kinds of blocks.

deck and die create random sources you can use in the generator. They both have this format, using deck as an example:

deck my deck name goes here
entry 1
entry 2
entry 3

A few things to note:

  • no quotes are needed anywhere
  • spaces in the name of the source are OK
  • each possible random value goes on its own line

The difference between a die and a deck is that a die can repeat values in one run of the generator, while a deck can not.

generator is the command that builds the widget. There are a lot of commands you can use inside it.

  • new-row: make a new row in the generator.
  • print: make a new cell in the row, and put text inside it. Terms inside [brackets] are taken to be the names of sources (dice or decks set before). Brackets can be nested.
  • image: like print, but it expects to get an image url. Any text after the url becomes a caption.
  • style: set the CSS attribute of the current row. Ex: style height 200px
  • roll: roll dice. Takes three values: number of dice to roll, sides per die, and bonus to apply. Ex: 2d6 + 1 → roll 2 6 1
  • col-widths: set widths of elements in the current row by ratio (uses flexbox).
  • save: saves the result of a template to a source with the given name. This is useful when you need to repeat the output of a template. This is a bit complicated, so here's an example:
    deck people
    Alice
    Bob

    generator
    save first [people]
    save second [people]
    print [first] said to [second] "Hello [second]"

There are also embedded commands that can go in text passed to print and the like. They work by starting the label inside brackets with an exclamation point. Currently there are just two:

  • roll: Roll dice in-line. Ex: print HP: [!r 1] (rolls 1d6) print STR: [!r 3 6 2] (rolls 3d6+2)
  • choose: Choose from an in-line list. The first non-whitespace character is used as the delimiter. Ex: print You see a [!c /wizard/fighter/thief/]

Command Line Features

You can pass in the path of json files like so:

shesha -d file.json -c file2.json -t file3.shesha "print this"

JSON files are assumed to be flat objects with keys that contain lists. To treat every key as a die use -d for Dice, to treat as a deck use -c for Cards, to read a template file using the same syntax as the web editor use -t (the generator function will be ignored). If you have the same key in multiple files, the contents of the key will be appended.

Arguments without a prefix are assumed to be templates for rendering and will be printed after interpolation.

Related Work / Similar Projects

License

WTFPL, do as you please.