diff options
Diffstat (limited to 'std/encoding')
-rw-r--r-- | std/encoding/binary.ts | 10 | ||||
-rw-r--r-- | std/encoding/binary_test.ts | 3 |
2 files changed, 5 insertions, 8 deletions
diff --git a/std/encoding/binary.ts b/std/encoding/binary.ts index e666dec26..2eec9b4ab 100644 --- a/std/encoding/binary.ts +++ b/std/encoding/binary.ts @@ -1,7 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { UnexpectedEOFError } from "../io/bufio.ts"; - type RawBaseTypes = "int8" | "int16" | "int32" | "uint8" | "uint16" | "uint32"; type RawNumberTypes = RawBaseTypes | "float32" | "float64"; type RawBigTypes = RawBaseTypes | "int64" | "uint64"; @@ -46,14 +44,14 @@ export function sizeof(dataType: RawTypes): number { /** Reads `n` bytes from `r`. * - * Returns it in a `Uint8Array`, or throws `UnexpectedEOFError` if `n` bytes cannot be read. */ + * Returns it in a `Uint8Array`, or throws `Deno.errors.UnexpectedEof` if `n` bytes cannot be read. */ export async function getNBytes( r: Deno.Reader, n: number ): Promise<Uint8Array> { const scratch = new Uint8Array(n); const nRead = await r.read(scratch); - if (nRead === Deno.EOF || nRead < n) throw new UnexpectedEOFError(); + if (nRead === Deno.EOF || nRead < n) throw new Deno.errors.UnexpectedEof(); return scratch; } @@ -199,7 +197,7 @@ export function putVarbig( /** Reads a number from `r`, comsuming `sizeof(o.dataType)` bytes. Data-type defaults to `int32`. * - * Returns it as `number`, or throws `UnexpectedEOFError` if not enough bytes can be read. */ + * Returns it as `number`, or throws `Deno.errors.UnexpectedEof` if not enough bytes can be read. */ export async function readVarnum( r: Deno.Reader, o: VarnumOptions = {} @@ -211,7 +209,7 @@ export async function readVarnum( /** Reads an integer from `r`, comsuming `sizeof(o.dataType)` bytes. Data-type defaults to `int64`. * - * Returns it as `bigint`, or throws `UnexpectedEOFError` if not enough bytes can be read. */ + * Returns it as `bigint`, or throws `Deno.errors.UnexpectedEof` if not enough bytes can be read. */ export async function readVarbig( r: Deno.Reader, o: VarbigOptions = {} diff --git a/std/encoding/binary_test.ts b/std/encoding/binary_test.ts index 9b541746b..a9f116ebc 100644 --- a/std/encoding/binary_test.ts +++ b/std/encoding/binary_test.ts @@ -1,7 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { assertEquals, assertThrowsAsync } from "../testing/asserts.ts"; -import { UnexpectedEOFError } from "../io/bufio.ts"; import { getNBytes, putVarbig, @@ -27,7 +26,7 @@ Deno.test(async function testGetNBytesThrows(): Promise<void> { const buff = new Deno.Buffer(data.buffer); assertThrowsAsync(async () => { await getNBytes(buff, 8); - }, UnexpectedEOFError); + }, Deno.errors.UnexpectedEof); }); Deno.test(async function testPutVarbig(): Promise<void> { |