Elpho LogoElpho

util module

Grab-bag utilities for arrays and randomness. Good for quick helpers without importing multiple modules.

Overview

util focuses on small helpers such as range, pick, and shuffle. Usecollections for heavier list transforms.

API

  • range(count) → array [0..count-1].
  • pick(array) → random element.
  • shuffle(array) → new shuffled copy.
Functions are non-mutating unless documented.

Examples

javascript
const util = use("util");
function main() {
const slots = util.range(5).map((i) => "Slot " + (i + 1));
ctx.reply("Slots: " + slots.join(", "));
}
javascript
const util = use("util");
function main() {
const items = ["apple", "berry", "cocoa"];
ctx.reply("You got: " + util.pick(items));
}