summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buffer.ts10
-rw-r--r--bufio_test.ts2
-rw-r--r--http_test.ts3
-rw-r--r--iotest.ts6
4 files changed, 8 insertions, 13 deletions
diff --git a/buffer.ts b/buffer.ts
index ba2715cef..d177bc18d 100644
--- a/buffer.ts
+++ b/buffer.ts
@@ -120,10 +120,7 @@ export class Buffer implements Reader, Writer {
* is drained. The return value n is the number of bytes read. If the
* buffer has no data to return, eof in the response will be true.
*/
- async read(p: ArrayBufferView): Promise<ReadResult> {
- if (!(p instanceof Uint8Array)) {
- throw Error("Only Uint8Array supported");
- }
+ async read(p: Uint8Array): Promise<ReadResult> {
if (this.empty()) {
// Buffer is empty, reset to recover space.
this.reset();
@@ -139,11 +136,8 @@ export class Buffer implements Reader, Writer {
return { nread, eof: false };
}
- async write(p: ArrayBufferView): Promise<number> {
+ async write(p: Uint8Array): Promise<number> {
const m = this._grow(p.byteLength);
- if (!(p instanceof Uint8Array)) {
- throw Error("Only Uint8Array supported");
- }
return copyBytes(this.buf, p, m);
}
diff --git a/bufio_test.ts b/bufio_test.ts
index f3430a755..5f32500a7 100644
--- a/bufio_test.ts
+++ b/bufio_test.ts
@@ -159,7 +159,7 @@ const testOutput = encoder.encode("0123456789abcdefghijklmnopqrstuvwxy");
class TestReader implements Reader {
constructor(private data: Uint8Array, private stride: number) {}
- async read(buf: ArrayBufferView): Promise<ReadResult> {
+ async read(buf: Uint8Array): Promise<ReadResult> {
let nread = this.stride;
if (nread > this.data.byteLength) {
nread = this.data.byteLength;
diff --git a/http_test.ts b/http_test.ts
index b0007a892..e6cb87f01 100644
--- a/http_test.ts
+++ b/http_test.ts
@@ -5,7 +5,8 @@ const addr = "0.0.0.0:8000";
const s = serve(addr);
console.log(`listening on http://${addr}/`);
-const body = new TextEncoder().encode("Hello World\n");
+const body = (new TextEncoder()).encode("Hello World\n");
+
async function main() {
for await (const req of s) {
diff --git a/iotest.ts b/iotest.ts
index e2498e155..e3a42f58a 100644
--- a/iotest.ts
+++ b/iotest.ts
@@ -11,7 +11,7 @@ import { Reader, ReadResult } from "deno";
export class OneByteReader implements Reader {
constructor(readonly r: Reader) {}
- async read(p: ArrayBufferView): Promise<ReadResult> {
+ async read(p: Uint8Array): Promise<ReadResult> {
if (p.byteLength === 0) {
return { nread: 0, eof: false };
}
@@ -28,7 +28,7 @@ export class OneByteReader implements Reader {
export class HalfReader implements Reader {
constructor(readonly r: Reader) {}
- async read(p: ArrayBufferView): Promise<ReadResult> {
+ async read(p: Uint8Array): Promise<ReadResult> {
if (!(p instanceof Uint8Array)) {
throw Error("expected Uint8Array");
}
@@ -51,7 +51,7 @@ export class TimeoutReader implements Reader {
count = 0;
constructor(readonly r: Reader) {}
- async read(p: ArrayBufferView): Promise<ReadResult> {
+ async read(p: Uint8Array): Promise<ReadResult> {
this.count++;
if (this.count === 2) {
throw new ErrTimeout();