ConstTruncate a string by weighted UTF-16 length.
Code units from U+0000 through U+00FF count as one; all other code units count as two. Optional truncation text is appended after the length limit. This does not measure bytes or rendered width and can split surrogate pairs.
Usage:
import { truncateByWeightedLength } from "mazey";
const ret = truncateByWeightedLength("hello world", 5);
console.log(ret);
Output:
hello
String to truncate.
Maximum weighted length.
OptionaldotText?: stringText appended when truncation occurs.
OptionalhasDot?: booleanWhether to append truncation text.
The truncated string.
Deprecated alias of truncateByWeightedLength.