diff options
| author | Ryan Dahl <ry@tinyclouds.org> | 2018-11-08 12:26:20 -0500 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2018-11-08 12:26:20 -0500 |
| commit | 0c324a442ef4a296bd925972dfbe3fc94c60b256 (patch) | |
| tree | 4e325e06de647c9ee7859a47dd6deedb0662d53a /buffer.ts | |
| parent | a628a499fa7794ef421e814ae487635890af1cb3 (diff) | |
First pass at TextProtoReader.
Original: https://github.com/denoland/deno_std/commit/31ab43b9193a9107d965c991f17992fcee791b33
Diffstat (limited to 'buffer.ts')
| -rw-r--r-- | buffer.ts | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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 */ |
