The strings module provides case insenstive methods like equalsIgnoreCase
,
includesIgnoreCase
, indexOfIgnoreCase
, startsWithIgnoreCase
, and
endsWithIgnoreCase
to avoid using string allocation by using comparisons with
toLowerCase/toUpperCase.
A Utf8StringBuilder
and StringBuilder
classes are included to avoid
uness unnecessary allocations for building text.
Trim methods that take other characters than whitespace for trimming a string.
import * from str from '@gnome/strings' console.log(str.equalIgnoreCase("left", "LeFT")); // true console.log(str.trimEnd("my random text...", ".")); // my random text console.log(str.underscore("first-place")); // first_place // useful for FFI var sb = new str.Utf8StringBuilder() sb.append("test") .append(new TextEncoder().encode(": another test")); // faster sb.appendString("test") .appendUtf8Array(new TextEncoder().encode(": another test")) console.log(sb.toString())
MIT License and additional MIT License for the inflection code, see License for details.
Add Package
deno add jsr:@gnome/strings
Import symbol
import * as strings from "@gnome/strings";
---- OR ----
Import directly with a jsr specifier
import * as strings from "jsr:@gnome/strings";
Add Package
npx jsr add @gnome/strings
Import symbol
import * as strings from "@gnome/strings";
Add Package
yarn dlx jsr add @gnome/strings
Import symbol
import * as strings from "@gnome/strings";
Add Package
pnpm dlx jsr add @gnome/strings
Import symbol
import * as strings from "@gnome/strings";
Add Package
bunx jsr add @gnome/strings
Import symbol
import * as strings from "@gnome/strings";