diff options
| author | Oliver Lenehan <sunsetkookaburra+github@outlook.com.au> | 2020-03-14 12:40:13 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-13 21:40:13 -0400 |
| commit | 0f6acf275370cae09ffb3f6950a3926424f3b024 (patch) | |
| tree | e77a2115394f36dcbd899fd8f2d5496ca7bde625 /std/encoding/binary.ts | |
| parent | aab1acaed163f91aa5e89b079c5312336abb2088 (diff) | |
fix(std): Use Deno.errors where possible. (#4356)
Diffstat (limited to 'std/encoding/binary.ts')
| -rw-r--r-- | std/encoding/binary.ts | 10 |
1 files changed, 4 insertions, 6 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 = {} |
