diff options
Diffstat (limited to 'js/util.ts')
-rw-r--r-- | js/util.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/js/util.ts b/js/util.ts index f65477ee5..c4bada589 100644 --- a/js/util.ts +++ b/js/util.ts @@ -85,6 +85,7 @@ export function unreachable(): never { throw new Error("Code not reachable"); } +// @internal export function hexdump(u8: Uint8Array): string { return Array.prototype.map .call(u8, (x: number) => { @@ -92,3 +93,11 @@ export function hexdump(u8: Uint8Array): string { }) .join(" "); } + +// @internal +export function containsOnlyASCII(str: string): boolean { + if (typeof str !== "string") { + return false; + } + return /^[\x00-\x7F]*$/.test(str); +} |