From 93ccb64f09f5f7c206650c563752054e033b01e5 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Thu, 12 Sep 2024 16:22:51 +1000 Subject: [PATCH] BREAKING(encoding/unstable): move `hex-stream` module to `unstable-hex-stream` (#5960) --- _tools/check_docs.ts | 1 + encoding/deno.json | 2 +- encoding/mod.ts | 1 - .../{hex_stream.ts => unstable_hex_stream.ts} | 16 ++++++++++++++-- ...tream_test.ts => unstable_hex_stream_test.ts} | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) rename encoding/{hex_stream.ts => unstable_hex_stream.ts} (80%) rename encoding/{hex_stream_test.ts => unstable_hex_stream_test.ts} (92%) diff --git a/_tools/check_docs.ts b/_tools/check_docs.ts index 9adfe7074..0a91420d9 100644 --- a/_tools/check_docs.ts +++ b/_tools/check_docs.ts @@ -48,6 +48,7 @@ const ENTRY_POINTS = [ "../encoding/unstable_base64_stream.ts", "../encoding/unstable_base32hex_stream.ts", "../encoding/unstable_base32_stream.ts", + "../encoding/unstable_hex_stream.ts", "../expect/mod.ts", "../fmt/bytes.ts", "../fmt/colors.ts", diff --git a/encoding/deno.json b/encoding/deno.json index ab1b5c086..f53f4a315 100644 --- a/encoding/deno.json +++ b/encoding/deno.json @@ -14,7 +14,7 @@ "./base64url": "./base64url.ts", "./base64url-stream": "./base64url_stream.ts", "./hex": "./hex.ts", - "./hex-stream": "./hex_stream.ts", + "./unstable-hex-stream": "./unstable_hex_stream.ts", "./varint": "./varint.ts" } } diff --git a/encoding/mod.ts b/encoding/mod.ts index 160fb868a..8f798e838 100644 --- a/encoding/mod.ts +++ b/encoding/mod.ts @@ -23,5 +23,4 @@ export * from "./base64.ts"; export * from "./base64url.ts"; export * from "./base64url_stream.ts"; export * from "./hex.ts"; -export * from "./hex_stream.ts"; export * from "./varint.ts"; diff --git a/encoding/hex_stream.ts b/encoding/unstable_hex_stream.ts similarity index 80% rename from encoding/hex_stream.ts rename to encoding/unstable_hex_stream.ts index 2cf3fdf2a..2cfc905fe 100644 --- a/encoding/hex_stream.ts +++ b/encoding/unstable_hex_stream.ts @@ -4,6 +4,18 @@ /** * Utilities for encoding and decoding to and from hex in a streaming manner. * + * ```ts + * import { assertEquals } from "@std/assert"; + * import { HexDecoderStream } from "@std/encoding/unstable-hex-stream"; + * import { toText } from "@std/streams/to-text"; + * + * const stream = ReadableStream.from(["48656c6c6f2c", "20776f726c6421"]) + * .pipeThrough(new HexDecoderStream()) + * .pipeThrough(new TextDecoderStream()); + * + * assertEquals(await toText(stream), "Hello, world!"); + * ``` + * * @experimental **UNSTABLE**: New API, yet to be vetted. * * @module @@ -22,7 +34,7 @@ import { decodeHex, encodeHex } from "./hex.ts"; * ```ts * import { assertEquals } from "@std/assert"; * import { encodeHex } from "@std/encoding/hex"; - * import { HexEncoderStream } from "@std/encoding/hex-stream"; + * import { HexEncoderStream } from "@std/encoding/unstable-hex-stream"; * import { toText } from "@std/streams/to-text"; * * const stream = ReadableStream.from(["Hello,", " world!"]) @@ -52,7 +64,7 @@ export class HexEncoderStream extends TransformStream { * @example Usage * ```ts * import { assertEquals } from "@std/assert"; - * import { HexDecoderStream } from "@std/encoding/hex-stream"; + * import { HexDecoderStream } from "@std/encoding/unstable-hex-stream"; * import { toText } from "@std/streams/to-text"; * * const stream = ReadableStream.from(["48656c6c6f2c", "20776f726c6421"]) diff --git a/encoding/hex_stream_test.ts b/encoding/unstable_hex_stream_test.ts similarity index 92% rename from encoding/hex_stream_test.ts rename to encoding/unstable_hex_stream_test.ts index 4bffafb97..70180b442 100644 --- a/encoding/hex_stream_test.ts +++ b/encoding/unstable_hex_stream_test.ts @@ -2,7 +2,7 @@ import { assertEquals } from "@std/assert"; import { encodeHex } from "./hex.ts"; -import { HexDecoderStream, HexEncoderStream } from "./hex_stream.ts"; +import { HexDecoderStream, HexEncoderStream } from "./unstable_hex_stream.ts"; import { toText } from "@std/streams/to-text"; import { concat } from "@std/bytes/concat"; import { RandomSliceStream } from "./_random_slice_stream.ts";