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

loot-ml

v0.1.0

Published

A language for creating loot tables

Downloads

2

Readme

LootML

LootML is a simple markup language for building loot tables.

Installation

yarn add loot-ml

Other useful scripts

npm run test
npm run build
npm run build-examples

API

compileCommonJS(input: string)
Compiles the given program to a commonJS module.

compileFunctions(input: string)
Compiles the given program to an object of executable functions (USES EVAL).

compileIIFE(input: string)
Compiles the given program to an IIFE that will return the exports object.

Example

import { compileFunctions } from 'loot-ml';

// or
// const compileFunctions = require('loot-ml');

const fns = compileFunctions(`
    @Fruits
    oneOf {
        item['Apple'],
        item['Pear'],
        item['Banana']
    }

    $FruitSalad
    repeat[4] {
        Fruits
    }

    $DeliciousSnack
    oneOf {
        Fruits,
        item['Mango']
    }
`);

fns.FruitSalad();
fns.DeliciousSnack();

Syntax

Structure

item[type, amount?]
An item entry for item type (string or number). Optionally specify an amount (default 1) either as a single number, or a range separated by -.

Examples:
item['item1']
item['item2', 10]
item['item3', 4-7]

selector[params] { weight? identifier, ... }
Makes a selection from the given list. selector is one of the selector types listed below. Some selectors allow weighting of different options using the number weight (default 1). identifier can be another selector, or an item.

Examples:

oneOf {
    item['item1'],
    item['item2']
}
allOf {
    someOf[2] {
        9 item['gold', 5],
        1 item['gold', 50]
    },
    oneOf {
        item['cloth scrap'],
        item['apple']
    }
}

@alias identifier
Creates an alias for identifier (either an item, a selector, or another alias) that can be used in its place.

Examples:

@MyItem item['myItemId', 1-2]

oneOf {
    MyItem,
    item['anotherItem']
}
@MySubTable
oneOf {
    item['someItem'],
    item['anotherItem']
}

oneOf {
    item['commonItem'],
    MySubTable
}

$export identifier
Exports the given identifier

Examples:

$MyExport
oneOf {
    item['someItem'],
    item['anotherItem']
}
$MyExport
@MyTable
oneOf {
    item['someItem'],
    item['anotherItem']
}

// or

@MyTable
$MyExport
oneOf {
    item['someItem'],
    item['anotherItem']
}

// or

@MyTable
oneOf {
    item['someItem'],
    item['anotherItem']
}

$MyExport MyTable

Selectors

oneOf
Chooses once from the given list

allOf
Chooses every entry in the given list (ignores weights)

someOf[n]
Chooses n times from the given list

Language extensions

It is possible to extend the language with additional selectors. To do so, either pass an array of selector objects as the second argument for new Parser(), or call addSelector() on the parser instance. Note that this should be done before calling parse(). See src/selectors for examples.

More documentation to come.

Built-in functions

$rand(n: number)
Returns Math.random() * n

$crand(n: number)
Returns Math.ceil(Math.random() * n)

$frand(n: number)
Returns Math.floor(Math.random() * n)

$cat(arr: Array<Array | any>)
Flattens the given array (NOT recursive)