Reject reactions with invalid number of graphemes

This commit is contained in:
Evan Hahn
2021-04-07 12:04:42 -05:00
committed by Josh Perez
parent 95482fbf31
commit f615b1a75f
5 changed files with 92 additions and 2 deletions
+6 -1
View File
@@ -1,7 +1,12 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { size } from './iterables';
import { map, size } from './iterables';
export function getGraphemes(str: string): Iterable<string> {
const segments = new Intl.Segmenter().segment(str);
return map(segments, s => s.segment);
}
export function count(str: string): number {
const segments = new Intl.Segmenter().segment(str);