summaryrefslogtreecommitdiff
path: root/std/io
diff options
context:
space:
mode:
Diffstat (limited to 'std/io')
-rw-r--r--std/io/bufio_test.ts9
-rw-r--r--std/io/util.ts30
-rw-r--r--std/io/util_test.ts18
3 files changed, 4 insertions, 53 deletions
diff --git a/std/io/bufio_test.ts b/std/io/bufio_test.ts
index d647082ad..03f699d50 100644
--- a/std/io/bufio_test.ts
+++ b/std/io/bufio_test.ts
@@ -17,7 +17,6 @@ import {
import * as iotest from "./_iotest.ts";
import { StringReader } from "./readers.ts";
import { StringWriter } from "./writers.ts";
-import { charCode } from "./util.ts";
import { copyBytes } from "../bytes/mod.ts";
const encoder = new TextEncoder();
@@ -140,7 +139,7 @@ Deno.test("bufioBufferFull", async function (): Promise<void> {
const decoder = new TextDecoder();
try {
- await buf.readSlice(charCode("!"));
+ await buf.readSlice("!".charCodeAt(0));
fail("readSlice should throw");
} catch (err) {
assert(err instanceof BufferFullError);
@@ -148,7 +147,7 @@ Deno.test("bufioBufferFull", async function (): Promise<void> {
assertEquals(decoder.decode(err.partial), "And now, hello, ");
}
- const line = await buf.readSlice(charCode("!"));
+ const line = await buf.readSlice("!".charCodeAt(0));
assert(line !== null);
const actual = decoder.decode(line);
assertEquals(actual, "world!");
@@ -332,7 +331,7 @@ Deno.test("bufioWriter", async function (): Promise<void> {
for (let i = 0; i < data.byteLength; i++) {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
- data[i] = charCode(" ") + (i % (charCode("~") - charCode(" ")));
+ data[i] = " ".charCodeAt(0) + (i % ("~".charCodeAt(0) - " ".charCodeAt(0)));
}
const w = new Deno.Buffer();
@@ -366,7 +365,7 @@ Deno.test("bufioWriterSync", function (): void {
for (let i = 0; i < data.byteLength; i++) {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
- data[i] = charCode(" ") + (i % (charCode("~") - charCode(" ")));
+ data[i] = " ".charCodeAt(0) + (i % ("~".charCodeAt(0) - " ".charCodeAt(0)));
}
const w = new Deno.Buffer();
diff --git a/std/io/util.ts b/std/io/util.ts
deleted file mode 100644
index 0055d7094..000000000
--- a/std/io/util.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import * as path from "../path/mod.ts";
-
-export function charCode(s: string): number {
- return s.charCodeAt(0);
-}
-
-/** Create or open a temporal file at specified directory with prefix and
- * postfix
- * */
-export async function tempFile(
- dir: string,
- opts: {
- prefix?: string;
- postfix?: string;
- } = { prefix: "", postfix: "" },
-): Promise<{ file: Deno.File; filepath: string }> {
- const r = Math.floor(Math.random() * 1000000);
- const filepath = path.resolve(
- `${dir}/${opts.prefix || ""}${r}${opts.postfix || ""}`,
- );
- await Deno.mkdir(path.dirname(filepath), { recursive: true });
- const file = await Deno.open(filepath, {
- create: true,
- read: true,
- write: true,
- append: true,
- });
- return { file, filepath };
-}
diff --git a/std/io/util_test.ts b/std/io/util_test.ts
deleted file mode 100644
index c602a90d3..000000000
--- a/std/io/util_test.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { assert } from "../testing/asserts.ts";
-import * as path from "../path/mod.ts";
-import { tempFile } from "./util.ts";
-
-Deno.test({
- name: "[io/util] tempfile",
- fn: async function (): Promise<void> {
- const f = await tempFile(".", {
- prefix: "prefix-",
- postfix: "-postfix",
- });
- const base = path.basename(f.filepath);
- assert(!!base.match(/^prefix-.+?-postfix$/));
- f.file.close();
- await Deno.remove(f.filepath);
- },
-});