Skip to content

Commit

Permalink
fix(std/io): remove trivial internal util.ts module (#8032)
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervonb authored Oct 20, 2020
1 parent 9cf06f7 commit 17467d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 56 deletions.
9 changes: 4 additions & 5 deletions std/io/bufio_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -140,15 +139,15 @@ 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);
assert(err.partial instanceof Uint8Array);
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!");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
30 changes: 0 additions & 30 deletions std/io/util.ts

This file was deleted.

18 changes: 0 additions & 18 deletions std/io/util_test.ts

This file was deleted.

9 changes: 6 additions & 3 deletions std/mime/multipart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { equal, findIndex, findLastIndex, hasPrefix } from "../bytes/mod.ts";
import { copyN } from "../io/ioutil.ts";
import { MultiReader } from "../io/readers.ts";
import { extname } from "../path/mod.ts";
import { tempFile } from "../io/util.ts";
import { BufReader, BufWriter } from "../io/bufio.ts";
import { encoder } from "../encoding/utf8.ts";
import { assert } from "../_util/assert.ts";
Expand Down Expand Up @@ -310,10 +309,14 @@ export class MultipartReader {
if (n > maxMemory) {
// too big, write to disk and flush buffer
const ext = extname(p.fileName);
const { file, filepath } = await tempFile(".", {
const filepath = await Deno.makeTempFile({
dir: ".",
prefix: "multipart-",
postfix: ext,
suffix: ext,
});

const file = await Deno.open(filepath, { write: true });

try {
const size = await Deno.copy(new MultiReader(buf, p), file);

Expand Down

0 comments on commit 17467d0

Please sign in to comment.