Packages
Packages you can install with cresset install. This registry is a plain folder of files served by this site, and every package in it is checked by its own tests before it is published. Installing shows you the permissions a package needs before you use it, and these are all pure: they can't read your files or use the network at all.
Every package here is released under the Apache License 2.0, like Cresset itself.
See the registry docs for how installing, publishing and the lock file work. The registry's address is https://cressetlang.org/registry, and you can browse the files directly: index.json.
stats 1.0.0
simple statistics for lists of numbers.
cresset install stats --registry https://cressetlang.org/registry
What it provides (9)
record Summary { count: num, mean: num, median: num, low: num, high: num, stdev: num } |
mean(xs) -> result[num] |
median(xs) -> result |
mode(xs) -> resultthe most common value; when several tie, the smallest |
variance(xs) -> result[num]variance of the whole list (divides by the count, not count - 1) |
stdev(xs) -> result[num] |
min_max(xs) -> result[list] |
percentile(xs, p) -> result[num]the p-th percentile, 0 to 100, with values between neighbours worked out in a straight line |
summarize(xs) -> result[Summary] |
textkit 1.0.0
everyday text helpers.
cresset install textkit --registry https://cressetlang.org/registry
What it provides (11)
slugify(text) -> text"Hello, World!" becomes "hello-world": lowercase, with runs of anything else turned into one dash |
truncate(text, limit, ending = ...)cut text down to at most `limit` characters, ending in `ending` when something was cut off |
wrap(text, width) -> listbreak text into lines of at most `width` characters, splitting only between words |
words(text) |
word_count(text) |
center(text, width, fill = ...)put `text` in the middle of a field `width` wide |
indent(text, spaces = ...)put `spaces` spaces in front of every line |
capitalize(text) |
camel_case(text) -> text"hello big world" becomes "helloBigWorld" |
snake_case(text)"Hello Big World" becomes "hello_big_world" |
is_palindrome(text) -> booldoes it read the same backwards, ignoring case, spaces and punctuation? |
listkit 1.0.0
helpers for working with lists.
cresset install listkit --registry https://cressetlang.org/registry
What it provides (10)
windows(items, size) -> listevery run of `size` neighbouring items |
pairwise(items) -> listpairs of neighbours: [1, 2, 3] becomes [[1, 2], [2, 3]] |
rotate(items, steps)move items around the end: rotate([1, 2, 3, 4], 1) is [2, 3, 4, 1] |
product(items) -> num |
cartesian(a, b) -> listevery pairing of an item from `a` with one from `b` |
transpose(rows) -> listrows become columns |
flatten_deep(items) -> listlists inside lists inside lists, all flattened into one |
frequencies(items) -> mapa map of each distinct item to how many times it appears |
range_step(start, stop, step) -> listnumbers from `start` up to (not including) `stop`, `step` apart; a negative step counts down |
best_by(items, score)the item `score` likes best (the first one, when there is a tie), or none for an empty list |
csvkit 1.0.0
read and write CSV text, including quoted fields.
cresset install csvkit --registry https://cressetlang.org/registry
What it provides (4)
parse(text, separator = ...) -> result[list]Text becomes a list of rows, each a list of text fields. Handles "quoted, fields", "" for a quote inside quotes, line breaks inside quotes, and both \n and \r\n line endings. An err comes back when a quote is never closed. |
with_header(rows) -> result[list]rows with a header line become a list of maps: [{"name": "Ada", "score": "90"}, ...] |
needs_quotes(field, separator) |
stringify(rows, separator = ...) -> textthe other way: rows become CSV text, quoting only the fields that need it |
datekit 1.0.0
calendar dates and the arithmetic on them.
cresset install datekit --registry https://cressetlang.org/registry
What it provides (13)
is_leap(year) -> bool |
days_in_month(year, month) -> num |
is_valid(year, month, day) -> bool |
to_days(date) -> numwhole days since 1970-01-01 (negative before it) |
from_days(days) -> list[num]the date that many days since 1970-01-01 |
add_days(date, n) -> list[num] |
days_between(a, b) -> numhow many days from `a` to `b` (negative when b is earlier) |
weekday(date) -> num0 for Monday up to 6 for Sunday |
weekday_name(date) -> text |
is_weekend(date) -> bool |
add_months(date, n) -> listadd months, keeping the day when it fits and otherwise using the last day of that month |
format_date(date) -> text2026-12-05 |
parse_date(text) -> result[list[num]]"2026-12-05" becomes ok([2026, 12, 5]); anything else is an err |
jsonkit 1.0.0
work with nested data (maps and lists, like the result of json_parse).
cresset install jsonkit --registry https://cressetlang.org/registry
What it provides (6)
dig(data, path, fallback = ...)Follow a path like "user.tags.1" through maps and lists. Numbers pick list items. Gives back `fallback` when any step is missing, so it never stops your program. |
pick(data, keys) -> mapa copy of a map with only the listed keys |
omit(data, keys) -> mapa copy of a map without the listed keys |
deep_merge(a, b) -> mapput two maps together; where both have a key and both values are maps, merge those too. Otherwise the second map wins. |
flatten_keys(data, prefix = ...) -> mapnested maps become one flat map with dotted keys: {"a": {"b": 1}} becomes {"a.b": 1} |
set_at(data, path, value) -> mapa copy of the data with the value at the path replaced, creating maps along the way when needed |
mathkit 1.0.0
number helpers that are not built in.
cresset install mathkit --registry https://cressetlang.org/registry
What it provides (11)
gcd(a, b) -> num |
lcm(a, b) -> num |
is_prime(n) -> bool |
prime_factors(n) -> listthe prime factors in order, with repeats: prime_factors(12) is [2, 2, 3] |
factorial(n) -> result[num] |
choose(n, k) -> numn things taken k at a time, in any order |
fibonacci(count) -> listthe first `count` Fibonacci numbers |
clamp_to(x, low, high)keep a number inside [low, high] |
lerp(a, b, t) -> numthe point `t` of the way from a to b: lerp(0, 10, 0.25) is 2.5 |
sign(x) -> num |
digits(n) -> listthe digits of a whole number: digits(407) is [4, 0, 7] |