From 82457fbc9fd536cd649f50c75ac816372bb88830 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Thu, 5 Dec 2024 16:10:42 -0500 Subject: [PATCH] doc: document smol (SmolUtil) lib --- src/putility/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/putility/README.md b/src/putility/README.md index 47b1ab37b..0f1e93a4f 100644 --- a/src/putility/README.md +++ b/src/putility/README.md @@ -10,6 +10,33 @@ Each class in this module is best described as an _idea_: Putility contains general purpose library functions. +### `putility.libs.smol` + +A small ("smol") library with commonly useful utility functions. This was +moved here from a utility class called SmolUtil that used to be in Puter's +backend. + +#### `ensure_array(value)` + +Wraps a value in an array if that value is not an array already. + +#### `add(...v)` + +Variadic sum function; nothing more. + +#### `split(str, sep, options)` + +Split a string by the specified separator. + +The parameter `options` is optional. It provided, it must be an object +and can have any of the following values: + +- `trim` - trim leading and trailing whitespace from each separated component +- `discard_empty` - discard empty components + +It is recommended to enable `trim` when `discard_empty` is enabled to also +remove whitespace-only strings. + ### `putility.libs.context` This library exports class **Context**. This provides a context object