countGraphemes and add debug package

This commit is contained in:
sawka
2024-08-28 17:12:52 -07:00
parent c9a1e9afe3
commit afcbb35341
3 changed files with 16 additions and 2 deletions
+10
View File
@@ -255,12 +255,22 @@ function getPrefixedSettings(settings: SettingsType, prefix: string): SettingsTy
return rtn;
}
function countGraphemes(str: string): number {
if (str == null) {
return 0;
}
// this exists (need to hack TS to get it to not show an error)
const seg = new (Intl as any).Segmenter(undefined, { granularity: "grapheme" });
return Array.from(seg.segment(str)).length;
}
export {
atomWithDebounce,
atomWithThrottle,
base64ToArray,
base64ToString,
boundNumber,
countGraphemes,
fireAndForget,
getPrefixedSettings,
getPromiseState,