countGraphemes and add debug package

This commit is contained in:
sawka 2024-08-28 17:12:37 -07:00
parent c9a1e9afe3
commit afcbb35341
3 changed files with 16 additions and 2 deletions

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,

View File

@ -38,6 +38,7 @@
"@storybook/react-vite": "^8.2.9",
"@storybook/test": "^8.2.9",
"@types/css-tree": "^2",
"@types/debug": "^4",
"@types/electron": "^1.6.10",
"@types/node": "^22.5.0",
"@types/papaparse": "^5",
@ -92,6 +93,7 @@
"color": "^4.2.3",
"css-tree": "^2.3.1",
"dayjs": "^1.11.13",
"debug": "^4.3.6",
"electron-updater": "6.3.4",
"fast-average-color": "^9.4.0",
"htl": "^0.3.1",

View File

@ -3377,7 +3377,7 @@ __metadata:
languageName: node
linkType: hard
"@types/debug@npm:^4.0.0, @types/debug@npm:^4.1.6":
"@types/debug@npm:^4, @types/debug@npm:^4.0.0, @types/debug@npm:^4.1.6":
version: 4.1.12
resolution: "@types/debug@npm:4.1.12"
dependencies:
@ -5689,7 +5689,7 @@ __metadata:
languageName: node
linkType: hard
"debug@npm:4, debug@npm:^4.0.0, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.4, debug@npm:^4.3.5":
"debug@npm:4, debug@npm:^4.0.0, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.4, debug@npm:^4.3.5, debug@npm:^4.3.6":
version: 4.3.6
resolution: "debug@npm:4.3.6"
dependencies:
@ -11721,6 +11721,7 @@ __metadata:
"@tanstack/react-table": "npm:^8.20.1"
"@types/color": "npm:^3.0.6"
"@types/css-tree": "npm:^2"
"@types/debug": "npm:^4"
"@types/electron": "npm:^1.6.10"
"@types/node": "npm:^22.5.0"
"@types/papaparse": "npm:^5"
@ -11743,6 +11744,7 @@ __metadata:
color: "npm:^4.2.3"
css-tree: "npm:^2.3.1"
dayjs: "npm:^1.11.13"
debug: "npm:^4.3.6"
electron: "npm:^32.0.1"
electron-builder: "npm:^24.13.3"
electron-updater: "npm:6.3.4"