mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
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:
parent
498700fc52
commit
71e1b13714
@ -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",
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
@ -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);
|
||||
});
|
Loading…
Reference in New Issue
Block a user