Perl's reverse(@list) returns a new list; JS's Array.prototype.reverse mutates its
receiver in place. Spreads into a fresh array first so converted code doesn't pick up a
mutation side effect the original Perl never had.
chomp(s: string): string
Perl's chomp($x) mutates $x in place, stripping exactly one trailing "\n" (Perl's
default $/ record separator — not "\r\n"). JS can't mutate a caller's local binding
through a function call, so converted code must reassign the result itself:
x = legacyCompat.chomp(x), mirroring chomp $x;'s own mutating spirit as closely as a
pure function can.
sprintf(format: string,...args: unknown[]): string
A minimal sprintf covering the format-spec subset actually used across the legacy
plugin corpus (%s, %d, %f with optional width/precision) — not a full reimplementation
of Perl's considerably larger sprintf grammar.
Mojo::UserAgent->new — see LegacyUserAgent's own docs for exactly what's covered. Every
plugin using this must still declare its own real target host(s) in declared_permissions
(constitution Principle IV); this shim runs inside that same already-permission-scoped
process, so it's bound by whatever --allow-net grant the plugin itself was started with,
same as a plugin calling fetch() directly would be.
getLogger(name: string,category: string): LegacyLogger
get_logger($name, $category) — see LegacyLogger's own docs for exactly what's covered.
htmlUnescape(s: string): string
Mojo::Util::html_unescape — decodes HTML entities (named: &/</"/etc.,
and numeric: '/'). No native JS equivalent outside a real DOM (a textarea
element's .value trick, unavailable in this Deno sandbox — there's no document), so
reimplemented directly against the HTML5 entity table's most common names rather than
pulling in a full HTML entity library for what the legacy plugin corpus only ever uses on
scraped titles/summaries (a handful of the same few entities in practice).
parseHtml(markup: string,xml?: boolean): LegacyDomNode
Mojo::DOM->new(html) / Mojo::DOM->new->xml(1)->parse(xml) — parses markup and returns
its root node. xml toggles case-sensitive tag matching (real XML/custom elements like
<Genre> in a ComicInfo.xml file) vs HTML's traditionally case-insensitive tag names; see
LegacyDomNode's own docs for what's covered.
sleep(seconds: number): Promise<void>
Perl's sleep($seconds) blocks synchronously; JS has no synchronous sleep, so this is a
setTimeout-backed Promise instead — every call site must await it (the converter's
own sleep mapping in render.rs always emits the await, forcing the enclosing function
async the same way an awaited ->get()/->post() Mojo call already does).
getVersion(): { version: string; homepage: string; }
LANraragi::Utils::Generic::get_version — legacy reads this straight out of its own
package.json (version/homepage fields) once and caches it; this returns the
equivalent static values for this project instead of trying to read a Rust crate's
Cargo.toml from within the Deno sandbox. Update these two literals if
Cargo.toml's [workspace.package] version/repository ever changes.
refType(x: unknown): string
Perl's ref($x) builtin — returns "HASH"/"ARRAY" for a hashref/arrayref, or "" for
anything else (a plain scalar, undef, etc.), matching Perl's own string-truthiness rule
closely enough that ref($x) used as a bare boolean condition (return if ref $x;) works
unmodified once translated. Only hashref/arrayref detection — real Perl ref() also
recognizes CODE/SCALAR/blessed-object-class-name, none of which the legacy plugin
corpus's own use of ref() ever tests for.
trim(s: string | null | undefined): string
LANraragi::Utils::String::trim — strips leading/trailing whitespace, returning "" for
null/undefined instead of throwing (unlike JS's own String.prototype.trim, which
requires a real string receiver).
fileparse(path: string,suffixPattern?: unknown): [string, string, string]
File::Basename::fileparse($path, $suffix_pattern) — every real call site in the legacy
plugin corpus passes the same "match a trailing dot plus any run of non-dot characters"
suffix pattern (i.e. "the last extension"), so the second argument is accepted but ignored
rather than genuinely interpreting an arbitrary suffix pattern. Returns
[name-without-extension, directory-with-trailing-slash, extension-with-leading-dot],
matching Perl's own return order.
redis_decode(s: string): string
LANraragi::Utils::Redis::redis_decode — legacy re-decodes a value read back from Redis
as UTF-8, since Perl's own Redis client hands back raw bytes. Deno's Redis client (and
every string this dispatcher otherwise touches) is already a proper UTF-8 JS string by the
time a plugin sees it, so this is a pure pass-through.