summaryrefslogtreecommitdiff
path: root/buffer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.ts')
-rw-r--r--buffer.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/buffer.ts b/buffer.ts
index a795bc842..ba2715cef 100644
--- a/buffer.ts
+++ b/buffer.ts
@@ -13,6 +13,12 @@ import { assert, copyBytes } from "./util.ts";
const MIN_READ = 512;
const MAX_SIZE = 2 ** 32 - 2;
+const encoder = new TextEncoder();
+export function stringsReader(s: string): Reader {
+ const ui8 = encoder.encode(s);
+ return new Buffer(ui8.buffer as ArrayBuffer);
+}
+
/** A Buffer is a variable-sized buffer of bytes with read() and write()
* methods. Based on https://golang.org/pkg/bytes/#Buffer
*/