From eb064eba09f56ca92623f4dc7655cb084c5c4db4 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 25 Sep 2024 13:58:16 +1000 Subject: [PATCH] BREAKING(io/unstable): remove `sliceLongToBytes()` (#6005) --- io/deno.json | 1 - io/mod.ts | 1 - io/slice_long_to_bytes.ts | 32 -------------------------------- io/slice_long_to_bytes_test.ts | 24 ------------------------ 4 files changed, 58 deletions(-) delete mode 100644 io/slice_long_to_bytes.ts delete mode 100644 io/slice_long_to_bytes_test.ts diff --git a/io/deno.json b/io/deno.json index 92c16e543..b3aee7b56 100644 --- a/io/deno.json +++ b/io/deno.json @@ -18,7 +18,6 @@ "./read-short": "./read_short.ts", "./read-string-delim": "./read_string_delim.ts", "./reader-from-stream-reader": "./reader_from_stream_reader.ts", - "./slice-long-to-bytes": "./slice_long_to_bytes.ts", "./string-reader": "./string_reader.ts", "./string-writer": "./string_writer.ts", "./to-readable-stream": "./to_readable_stream.ts", diff --git a/io/mod.ts b/io/mod.ts index 4b280c8bc..e8ad4bf6f 100644 --- a/io/mod.ts +++ b/io/mod.ts @@ -31,7 +31,6 @@ export * from "./read_range.ts"; export * from "./read_short.ts"; export * from "./read_string_delim.ts"; export * from "./reader_from_stream_reader.ts"; -export * from "./slice_long_to_bytes.ts"; export * from "./string_reader.ts"; export * from "./string_writer.ts"; export * from "./to_readable_stream.ts"; diff --git a/io/slice_long_to_bytes.ts b/io/slice_long_to_bytes.ts deleted file mode 100644 index f3b48e032..000000000 --- a/io/slice_long_to_bytes.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. - -/** - * Slice number into 64bit big endian byte array. - * - * @example Usage - * ```ts - * import { sliceLongToBytes } from "@std/io/slice-long-to-bytes"; - * import { assertEquals } from "@std/assert/equals"; - * - * const dest = sliceLongToBytes(0x123456789a); - * assertEquals(dest, [0, 0, 0, 0x12, 0x34, 0x56, 0x78, 0x9a]); - * ``` - * - * @param d The number to be sliced - * @param dest The array to store the sliced bytes - * @returns The sliced bytes - * - * @deprecated This will be removed in 0.225.0. - */ -export function sliceLongToBytes( - d: number, - dest: number[] = Array.from({ length: 8 }), -): number[] { - let big = BigInt(d); - for (let i = 0; i < 8; i++) { - dest[7 - i] = Number(big & 0xffn); - big >>= 8n; - } - return dest; -} diff --git a/io/slice_long_to_bytes_test.ts b/io/slice_long_to_bytes_test.ts deleted file mode 100644 index 2aaf75c59..000000000 --- a/io/slice_long_to_bytes_test.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { assertEquals } from "@std/assert"; -import { readLong } from "./read_long.ts"; -import { sliceLongToBytes } from "./slice_long_to_bytes.ts"; -import { BufReader } from "./buf_reader.ts"; -import { BinaryReader } from "./_test_common.ts"; - -Deno.test("testSliceLongToBytes", function () { - const arr = sliceLongToBytes(0x1234567890abcdef); - const actual = readLong(new BufReader(new BinaryReader(new Uint8Array(arr)))); - const expected = readLong( - new BufReader( - new BinaryReader( - new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]), - ), - ), - ); - assertEquals(actual, expected); -}); - -Deno.test("testSliceLongToBytes2", function () { - const arr = sliceLongToBytes(0x12345678); - assertEquals(arr, [0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]); -});