The lulu
Library
Project Overview
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 converting Lua objects to strings that can gracefully handle recursive and shared tables.
Available Modules
Module | Purpose |
---|---|
lulu.Array |
A full-featured Array class for Lua. |
lulu.Enum |
An Enum class for Lua. |
lulu.callable |
Building “anonymous” functions from strings etc. |
lulu.messages |
Informational and error messages used throughout lulu . |
lulu.scribe |
Convert 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 |
Rudimentary path query methods. |
lulu.types |
Type-checking methods. |
Installation & Use
lulu
has no dependencies. Copy the lulu
directory and start using it.
Released versions will also be uploaded to the luarocks repository, so you should be able to install them using:
luarocks install lulu
Usage
Assuming your path allows it, you can require('lulu.lulu')
and have access to all the modules:
require('lulu.lulu')
'Suit' {
ENUM 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 ]
Documentation
Here is a link to the project’s source code repository.
This documentation site was constructed using the static website generator Quarto.
Acknowledgements
This library owes a lot to Penlight and the many questions that have been answered over the years on sites like StackOverflow and Reddit.
Contact
You can contact me by email
Copyright and License
Copyright (c) 2025-present Nessan Fitzmaurice.
You can use this software under the MIT License