summaryrefslogtreecommitdiff
path: root/js/util.ts
diff options
context:
space:
mode:
authorParsa Ghadimi <me@qti3e.com>2018-09-14 17:15:50 +0430
committerRyan Dahl <ry@tinyclouds.org>2018-09-14 10:04:10 -0700
commit7b7052e1abb0735ca443ffd133b014a19b7dab3d (patch)
treecee20d0143b9a0a7545b60ab329a17d1e17d9c11 /js/util.ts
parentaaf70ca092fb9866bd50725f8f5b67be6f6879e3 (diff)
Implement Blob
Diffstat (limited to 'js/util.ts')
-rw-r--r--js/util.ts9
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);
+}