BREAKING(io): remove readInt() (#6048)

* BREAKING(io/unstable): remove `sliceLongToBytes()`

* BREAKINIG(io/unstable): remove `readLong()`

* BREAKING(io/unstable): remove `readInt()`
This commit is contained in:
Asher Gomez 2024-09-25 14:13:37 +10:00 committed by GitHub
parent 498700fc52
commit 71e1b13714
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 0 additions and 46 deletions

View File

@ -12,7 +12,6 @@
"./multi-reader": "./multi_reader.ts",
"./read-all": "./read_all.ts",
"./read-delim": "./read_delim.ts",
"./read-int": "./read_int.ts",
"./read-short": "./read_short.ts",
"./reader-from-stream-reader": "./reader_from_stream_reader.ts",
"./string-reader": "./string_reader.ts",

View File

@ -25,7 +25,6 @@ export * from "./limited_reader.ts";
export * from "./multi_reader.ts";
export * from "./read_all.ts";
export * from "./read_delim.ts";
export * from "./read_int.ts";
export * from "./read_short.ts";
export * from "./reader_from_stream_reader.ts";
export * from "./string_reader.ts";

View File

@ -1,32 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import type { BufReader } from "./buf_reader.ts";
import { readShort } from "./read_short.ts";
/**
* Read big endian 32bit integer from a {@linkcode BufReader}.
*
* @example Usage
* ```ts
* import { Buffer } from "@std/io/buffer"
* import { BufReader } from "@std/io/buf-reader";
* import { readInt } from "@std/io/read-int";
* import { assertEquals } from "@std/assert/equals";
*
* const buf = new BufReader(new Buffer(new Uint8Array([0x12, 0x34, 0x56, 0x78])));
* const int = await readInt(buf);
* assertEquals(int, 0x12345678);
* ```
*
* @param buf The buffer reader to read from
* @returns The 32bit integer
*
* @deprecated This will be removed in 0.225.0.
*/
export async function readInt(buf: BufReader): Promise<number | null> {
const high = await readShort(buf);
if (high === null) return null;
const low = await readShort(buf);
if (low === null) throw new Deno.errors.UnexpectedEof();
return (high << 16) | low;
}

View File

@ -1,12 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "@std/assert";
import { readInt } from "./read_int.ts";
import { BufReader } from "./buf_reader.ts";
import { BinaryReader } from "./_test_common.ts";
Deno.test("testReadInt", async function () {
const r = new BinaryReader(new Uint8Array([0x12, 0x34, 0x56, 0x78]));
const int = await readInt(new BufReader(r));
assertEquals(int, 0x12345678);
});