Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Utilities

Perry natively implements common utility packages.

lodash

The lodash runtime functions are partially implemented (see crates/perry-stdlib/src/lodash.rs) but the user-facing dispatch from import _ from "lodash"; _.chunk(...) is not wired into the LLVM backend yet. Track the follow-up at issue #200.

import _ from "lodash";

_.chunk([1, 2, 3, 4, 5], 2);     // [[1,2], [3,4], [5]]
_.uniq([1, 2, 2, 3, 3]);          // [1, 2, 3]
_.groupBy(users, "role");
_.sortBy(users, ["name"]);
_.cloneDeep(obj);
_.merge(defaults, overrides);
_.debounce(fn, 300);
_.throttle(fn, 100);

dayjs

dayjs runtime functions are declared (js_dayjs_now, js_dayjs_format, js_dayjs_add, etc.) but the user-facing dispatch from import dayjs from "dayjs"; dayjs() chained methods is not wired into the LLVM backend yet. Track the follow-up at issue #200.

import dayjs from "dayjs";

const now = dayjs();
console.log(now.format("YYYY-MM-DD"));
console.log(now.add(7, "day").format("YYYY-MM-DD"));
console.log(now.subtract(1, "month").toISOString());

const diff = dayjs("2025-12-31").diff(now, "day");
console.log(`${diff} days until end of year`);

moment

Same status as dayjs — the runtime functions exist but the dispatch path is not wired yet.

import moment from "moment";

const now = moment();
console.log(now.format("MMMM Do YYYY"));
console.log(now.fromNow());
console.log(moment("2025-01-01").isBefore(now));

uuid

import { v4 as uuidv4 } from "uuid"

const id = uuidv4()
console.log(id) // e.g., "550e8400-e29b-41d4-a716-446655440000"

nanoid

The default-length nanoid() call is wired. The custom-length form nanoid(10) has a runtime function (js_nanoid_sized) but no dispatch yet — track at issue #200.

import { nanoid } from "nanoid"

const nid = nanoid() // Default 21 chars
console.log(nid)

slugify

The single-arg form is wired. The options-object form slugify("Hello World!", { lower: true }) has a runtime function (js_slugify_with_options) but no dispatch yet — track at issue #200.

import slugify from "slugify"

const slug = slugify("Hello World!")
console.log(slug) // "hello-world"

validator

import validator from "validator"

console.log(validator.isEmail("test@example.com"))  // true
console.log(validator.isURL("https://example.com")) // true
console.log(validator.isUUID(id))                   // true
console.log(validator.isEmpty(""))                  // true

Next Steps