summaryrefslogtreecommitdiff
path: root/std/io/_iotest.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-02-02 19:05:46 +0800
committerGitHub <noreply@github.com>2021-02-02 12:05:46 +0100
commit6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch)
treefd94c013a19fcb38954844085821ec1601c20e18 /std/io/_iotest.ts
parenta2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff)
chore: remove std directory (#9361)
This removes the std folder from the tree. Various parts of the tests are pretty tightly dependent on std (47 direct imports and 75 indirect imports, not counting the cli tests that use them as fixtures) so I've added std as a submodule for now.
Diffstat (limited to 'std/io/_iotest.ts')
-rw-r--r--std/io/_iotest.ts53
1 files changed, 0 insertions, 53 deletions
diff --git a/std/io/_iotest.ts b/std/io/_iotest.ts
deleted file mode 100644
index 5905d2552..000000000
--- a/std/io/_iotest.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.// Ported to Deno from
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-type Reader = Deno.Reader;
-
-/** OneByteReader returns a Reader that implements
- * each non-empty Read by reading one byte from r.
- */
-export class OneByteReader implements Reader {
- constructor(readonly r: Reader) {}
-
- read(p: Uint8Array): Promise<number | null> {
- if (p.byteLength === 0) {
- return Promise.resolve(0);
- }
- if (!(p instanceof Uint8Array)) {
- throw Error("expected Uint8Array");
- }
- return Promise.resolve(this.r.read(p.subarray(0, 1)));
- }
-}
-
-/** HalfReader returns a Reader that implements Read
- * by reading half as many requested bytes from r.
- */
-export class HalfReader implements Reader {
- constructor(readonly r: Reader) {}
-
- read(p: Uint8Array): Promise<number | null> {
- if (!(p instanceof Uint8Array)) {
- throw Error("expected Uint8Array");
- }
- const half = Math.floor((p.byteLength + 1) / 2);
- return Promise.resolve(this.r.read(p.subarray(0, half)));
- }
-}
-
-/** TimeoutReader returns `Deno.errors.TimedOut` on the second read
- * with no data. Subsequent calls to read succeed.
- */
-export class TimeoutReader implements Reader {
- count = 0;
- constructor(readonly r: Reader) {}
-
- read(p: Uint8Array): Promise<number | null> {
- this.count++;
- if (this.count === 2) {
- throw new Deno.errors.TimedOut();
- }
- return Promise.resolve(this.r.read(p));
- }
-}