openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
15 lines (14 loc) • 404 B
JavaScript
//#region packages/normalization-core/src/code-points.ts
/** Truncates to a nonnegative code-point budget; grapheme clusters may be split. */
function truncateCodePoints(e, t) {
const n = Math.max(0, Math.trunc(t) || 0);
if (e.length <= n) return e;
const r = [];
for (const t of e) {
if (r.length >= n) break;
r.push(t);
}
return r.join("");
}
//#endregion
export { truncateCodePoints as t };