lulu is a collection of Lua utility modules and classes.
It includes a full-featured Array class, an Enum class, and a variety of other utility functions and extensions. It also includes a copy of scribe, a Lua module for formatted output that gracefully handles Lua tables.
Everyone creates one of these little libraries. This one has a comprehensive long-form documentation site built using Quarto.
| Module | Purpose |
|---|---|
lulu.Array |
A full-featured Array class for Lua. |
lulu.Enum |
An Enum class for Lua. |
lulu.callable |
Builds "anonymous" functions from strings, etc. a la Penlight.etc. |
lulu.messages |
Informational and error messages used throughout lulu. |
lulu.scribe |
Converts Lua objects to strings. Gracefully handles recursive and shared tables. |
lulu.table |
Lua table extensions that work on any table. |
lulu.string |
Lua string extensions that are added to all string objects. |
lulu.xpeg |
An extended lpeg module with predefined patterns and useful functions. |
lulu.paths |
Some rudimentary path query methods. |
lulu.types |
Type-checking methods. |
lulu has no dependencies. Copy the lulu directory and start using it.
Released versions of lulu will be uploaded to LuaRocks, so you should be able to install the library using:
luarocks install luluAssuming your path allows it, you can require('lulu.lulu') and have access to all the modules:
require('lulu.lulu')
ENUM 'Suit' {
Clubs = { abbrev = 'C', color = 'black', icon = '♣', ordinal = 0 },
Diamonds = { abbrev = 'D', color = 'red', icon = '♦', ordinal = 1 },
Hearts = { abbrev = 'H', color = 'red', icon = '♥', ordinal = 2 },
Spades = { abbrev = 'S', color = 'black', icon = '♠', ordinal = 3 }
}
scribe.putln("%T", Suit)That will output:
Suit:
[0] Clubs = { abbrev = "C", color = "black", icon = "♣" },
[1] Diamonds = { abbrev = "D", color = "red", icon = "♦" },
[2] Hearts = { abbrev = "H", color = "red", icon = "♥" },
[3] Spades = { abbrev = "S", color = "black", icon = "♠" }Alternatively, you can access the modules individually:
local scribe = require('lulu.scribe')
local Array = require('lulu.Array')
local array = Array(1, 2, 3)
array:transform("*", 10)
scribe.putln("array = %t", array)This will output:
array = [ 10, 20, 30 ]lulu is fully documented here.
We built the documentation site using Quarto.
This library owes a lot to Penlight and the many questions answered over the years on sites like StackOverflow and Reddit.
You can contact me by email here.
Copyright (c) 2025-present Nessan Fitzmaurice. You can use this software under the MIT license.