diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2020-07-14 15:24:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 15:24:17 -0400 |
commit | cde4dbb35132848ffece59ef9cfaccff32347124 (patch) | |
tree | cc7830968c6decde704c8cfb83c9185193dc698f /std/io | |
parent | 9eca71caa1674c31f9cc5d4e86c03f10b59e0a00 (diff) |
Use dprint for internal formatting (#6682)
Diffstat (limited to 'std/io')
-rw-r--r-- | std/io/bufio.ts | 16 | ||||
-rw-r--r-- | std/io/bufio_test.ts | 19 | ||||
-rw-r--r-- | std/io/ioutil.ts | 4 | ||||
-rw-r--r-- | std/io/ioutil_test.ts | 10 | ||||
-rw-r--r-- | std/io/streams.ts | 4 | ||||
-rw-r--r-- | std/io/streams_test.ts | 4 | ||||
-rw-r--r-- | std/io/util.ts | 4 |
7 files changed, 30 insertions, 31 deletions
diff --git a/std/io/bufio.ts b/std/io/bufio.ts index a1e6f67aa..682f96499 100644 --- a/std/io/bufio.ts +++ b/std/io/bufio.ts @@ -95,7 +95,7 @@ export class BufReader implements Reader { } throw new Error( - `No progress after ${MAX_CONSECUTIVE_EMPTY_READS} read() calls` + `No progress after ${MAX_CONSECUTIVE_EMPTY_READS} read() calls`, ); } @@ -252,7 +252,7 @@ export class BufReader implements Reader { let { partial } = err; assert( partial instanceof Uint8Array, - "bufio: caught error from `readSlice()` without `partial` property" + "bufio: caught error from `readSlice()` without `partial` property", ); // Don't throw if `readSlice()` failed with `BufferFullError`, instead we @@ -466,7 +466,7 @@ export class BufWriter extends AbstractBufBase implements Writer { try { await Deno.writeAll( this.writer, - this.buf.subarray(0, this.usedBufferBytes) + this.buf.subarray(0, this.usedBufferBytes), ); } catch (e) { this.err = e; @@ -527,7 +527,7 @@ export class BufWriterSync extends AbstractBufBase implements WriterSync { /** return new BufWriterSync unless writer is BufWriterSync */ static create( writer: WriterSync, - size: number = DEFAULT_BUF_SIZE + size: number = DEFAULT_BUF_SIZE, ): BufWriterSync { return writer instanceof BufWriterSync ? writer @@ -559,7 +559,7 @@ export class BufWriterSync extends AbstractBufBase implements WriterSync { try { Deno.writeAllSync( this.writer, - this.buf.subarray(0, this.usedBufferBytes) + this.buf.subarray(0, this.usedBufferBytes), ); } catch (e) { this.err = e; @@ -633,7 +633,7 @@ function createLPS(pat: Uint8Array): Uint8Array { /** Read delimited bytes from a Reader. */ export async function* readDelim( reader: Reader, - delim: Uint8Array + delim: Uint8Array, ): AsyncIterableIterator<Uint8Array> { // Avoid unicode problems const delimLen = delim.length; @@ -692,7 +692,7 @@ export async function* readDelim( /** Read delimited strings from a Reader. */ export async function* readStringDelim( reader: Reader, - delim: string + delim: string, ): AsyncIterableIterator<string> { const encoder = new TextEncoder(); const decoder = new TextDecoder(); @@ -704,7 +704,7 @@ export async function* readStringDelim( /** Read strings line-by-line from a Reader. */ // eslint-disable-next-line require-await export async function* readLines( - reader: Reader + reader: Reader, ): AsyncIterableIterator<string> { yield* readStringDelim(reader, "\n"); } diff --git a/std/io/bufio_test.ts b/std/io/bufio_test.ts index ad02703de..1ad6c7ac6 100644 --- a/std/io/bufio_test.ts +++ b/std/io/bufio_test.ts @@ -122,8 +122,7 @@ Deno.test("bufioBufReader", async function (): Promise<void> { const read = readmaker.fn(new StringReader(text)); const buf = new BufReader(read, bufsize); const s = await bufreader.fn(buf); - const debugStr = - `reader=${readmaker.name} ` + + const debugStr = `reader=${readmaker.name} ` + `fn=${bufreader.name} bufsize=${bufsize} want=${text} got=${s}`; assertEquals(s, text, debugStr); } @@ -179,11 +178,11 @@ Deno.test("bufioReadString", async function (): Promise<void> { }); const testInput = encoder.encode( - "012\n345\n678\n9ab\ncde\nfgh\nijk\nlmn\nopq\nrst\nuvw\nxy" + "012\n345\n678\n9ab\ncde\nfgh\nijk\nlmn\nopq\nrst\nuvw\nxy", ); const testInputrn = encoder.encode( "012\r\n345\r\n678\r\n9ab\r\ncde\r\nfgh\r\nijk\r\nlmn\r\nopq\r\nrst\r\n" + - "uvw\r\nxy\r\n\n\r\n" + "uvw\r\nxy\r\n\n\r\n", ); const testOutput = encoder.encode("0123456789abcdefghijklmnopqrstuvwxy"); @@ -225,7 +224,7 @@ async function testReadLine(input: Uint8Array): Promise<void> { assertEquals( line, want, - `Bad line at stride ${stride}: want: ${want} got: ${line}` + `Bad line at stride ${stride}: want: ${want} got: ${line}`, ); done += line.byteLength; } @@ -233,7 +232,7 @@ async function testReadLine(input: Uint8Array): Promise<void> { done, testOutput.byteLength, `readLine didn't return everything: got: ${done}, ` + - `want: ${testOutput} (stride: ${stride})` + `want: ${testOutput} (stride: ${stride})`, ); } } @@ -249,7 +248,7 @@ Deno.test("bufioPeek", async function (): Promise<void> { // string is 16 (minReadBufferSize) long. const buf = new BufReader( new StringReader("abcdefghijklmnop"), - MIN_READ_BUFFER_SIZE + MIN_READ_BUFFER_SIZE, ); let actual = await buf.peek(1); @@ -425,7 +424,7 @@ Deno.test("bufReaderReadFull", async function (): Promise<void> { Deno.test("readStringDelimAndLines", async function (): Promise<void> { const enc = new TextEncoder(); const data = new Deno.Buffer( - enc.encode("Hello World\tHello World 2\tHello World 3") + enc.encode("Hello World\tHello World 2\tHello World 3"), ); const chunks_ = []; @@ -464,9 +463,9 @@ Deno.test( assertEquals(decoder.decode(r2.line), "z"); assert( r1.line.buffer !== r2.line.buffer, - "array buffer should not be shared across reads" + "array buffer should not be shared across reads", ); - } + }, ); Deno.test({ diff --git a/std/io/ioutil.ts b/std/io/ioutil.ts index ac6d103a3..da48e95ab 100644 --- a/std/io/ioutil.ts +++ b/std/io/ioutil.ts @@ -12,7 +12,7 @@ const DEFAULT_BUFFER_SIZE = 32 * 1024; export async function copyN( r: Reader, dest: Writer, - size: number + size: number, ): Promise<number> { let bytesRead = 0; let buf = new Uint8Array(DEFAULT_BUFFER_SIZE); @@ -67,7 +67,7 @@ export async function readLong(buf: BufReader): Promise<number | null> { // We probably should provide a similar API that returns BigInt values. if (big > MAX_SAFE_INTEGER) { throw new RangeError( - "Long value too big to be represented as a JavaScript number." + "Long value too big to be represented as a JavaScript number.", ); } return Number(big); diff --git a/std/io/ioutil_test.ts b/std/io/ioutil_test.ts index dfdda23fb..69f76f691 100644 --- a/std/io/ioutil_test.ts +++ b/std/io/ioutil_test.ts @@ -38,7 +38,7 @@ Deno.test("testReadInt", async function (): Promise<void> { Deno.test("testReadLong", async function (): Promise<void> { const r = new BinaryReader( - new Uint8Array([0x00, 0x00, 0x00, 0x78, 0x12, 0x34, 0x56, 0x78]) + new Uint8Array([0x00, 0x00, 0x00, 0x78, 0x12, 0x34, 0x56, 0x78]), ); const long = await readLong(new BufReader(r)); assertEquals(long, 0x7812345678); @@ -46,7 +46,7 @@ Deno.test("testReadLong", async function (): Promise<void> { Deno.test("testReadLong2", async function (): Promise<void> { const r = new BinaryReader( - new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]) + new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]), ); const long = await readLong(new BufReader(r)); assertEquals(long, 0x12345678); @@ -58,9 +58,9 @@ Deno.test("testSliceLongToBytes", function (): void { const expected = readLong( new BufReader( new BinaryReader( - new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]) - ) - ) + new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]), + ), + ), ); assertEquals(actual, expected); }); diff --git a/std/io/streams.ts b/std/io/streams.ts index 3969746ef..89cc6bd45 100644 --- a/std/io/streams.ts +++ b/std/io/streams.ts @@ -1,7 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. export function fromStreamWriter( - streamWriter: WritableStreamDefaultWriter<Uint8Array> + streamWriter: WritableStreamDefaultWriter<Uint8Array>, ): Deno.Writer { return { async write(p: Uint8Array): Promise<number> { @@ -13,7 +13,7 @@ export function fromStreamWriter( } export function fromStreamReader( - streamReader: ReadableStreamDefaultReader<Uint8Array> + streamReader: ReadableStreamDefaultReader<Uint8Array>, ): Deno.Reader { const buffer = new Deno.Buffer(); diff --git a/std/io/streams_test.ts b/std/io/streams_test.ts index 00d056e2f..4579e3668 100644 --- a/std/io/streams_test.ts +++ b/std/io/streams_test.ts @@ -64,7 +64,7 @@ Deno.test("toReaderCheck", async function (): Promise<void> { assertEquals( expected, - readChunks.map((chunk) => decoder.decode(chunk)) + readChunks.map((chunk) => decoder.decode(chunk)), ); }); @@ -115,7 +115,7 @@ Deno.test("toReaderBigIrregularChunksCheck", async function (): Promise<void> { chunks .slice() .map((chunk) => [...chunk]) - .flat() + .flat(), ); const readableStream = new ReadableStream({ pull(controller): void { diff --git a/std/io/util.ts b/std/io/util.ts index f4b7bf8bb..0055d7094 100644 --- a/std/io/util.ts +++ b/std/io/util.ts @@ -13,11 +13,11 @@ export async function tempFile( opts: { prefix?: string; postfix?: string; - } = { prefix: "", postfix: "" } + } = { 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 || ""}` + `${dir}/${opts.prefix || ""}${r}${opts.postfix || ""}`, ); await Deno.mkdir(path.dirname(filepath), { recursive: true }); const file = await Deno.open(filepath, { |