summaryrefslogtreecommitdiff
path: root/std/strings/encode.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/strings/encode.ts')
-rw-r--r--std/strings/encode.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/std/strings/encode.ts b/std/strings/encode.ts
new file mode 100644
index 000000000..285305613
--- /dev/null
+++ b/std/strings/encode.ts
@@ -0,0 +1,7 @@
+/** A default TextEncoder instance */
+export const encoder = new TextEncoder();
+
+/** Shorthand for new TextEncoder().encode() */
+export function encode(input?: string): Uint8Array {
+ return encoder.encode(input);
+}