diff --git a/streams/buffer.ts b/streams/buffer.ts index 37e02f8a1..bbbbc8a64 100644 --- a/streams/buffer.ts +++ b/streams/buffer.ts @@ -131,29 +131,6 @@ export class Buffer { * Constructs a new instance. * * @param ab An optional buffer to use as the initial buffer. - * - * @example No initial buffer provided - * ```ts no-assert - * import { Buffer } from "@std/streams/buffer"; - * - * const buf = new Buffer(); - * ``` - * - * @example With a pre-allocated buffer - * ```ts no-assert - * import { Buffer } from "@std/streams/buffer"; - * - * const arrayBuffer = new ArrayBuffer(8); - * const buf = new Buffer(arrayBuffer); - * ``` - * - * @example From Uint8Array - * ```ts no-assert - * import { Buffer } from "@std/streams/buffer"; - * - * const array = new Uint8Array([0, 1, 2]); - * const buf = new Buffer(array.buffer); - * ``` */ constructor(ab?: ArrayBufferLike | ArrayLike) { this.#buf = ab === undefined ? new Uint8Array(0) : new Uint8Array(ab); diff --git a/streams/byte_slice_stream.ts b/streams/byte_slice_stream.ts index c4ad6def4..75390eacc 100644 --- a/streams/byte_slice_stream.ts +++ b/streams/byte_slice_stream.ts @@ -43,20 +43,6 @@ export class ByteSliceStream extends TransformStream { * * @param start The zero-indexed byte index to start reading from. * @param end The zero-indexed byte index to stop reading at. Inclusive. - * - * @example No parameters - * ```ts no-assert - * import { ByteSliceStream } from "@std/streams/byte-slice-stream"; - * - * const byteSliceStream = new ByteSliceStream(); - * ``` - * - * @example start = 4, end = 11 - * ```ts no-assert - * import { ByteSliceStream } from "@std/streams/byte-slice-stream"; - * - * const byteSliceStream = new ByteSliceStream(4, 11); - * ``` */ constructor(start = 0, end: number = Infinity) { super({ diff --git a/streams/delimiter_stream.ts b/streams/delimiter_stream.ts index 998843124..a91d719fe 100644 --- a/streams/delimiter_stream.ts +++ b/streams/delimiter_stream.ts @@ -74,22 +74,6 @@ export class DelimiterStream extends TransformStream { * * @param delimiter A delimiter to split the stream by. * @param options Options for the delimiter stream. - * - * @example comma as a delimiter - * ```ts no-assert - * import { DelimiterStream } from "@std/streams/delimiter-stream"; - * - * const delimiterStream = new DelimiterStream(new TextEncoder().encode(",")); - * ``` - * - * @example semicolon as a delimiter, and disposition set to `"suffix"` - * ```ts no-assert - * import { DelimiterStream } from "@std/streams/delimiter-stream"; - * - * const delimiterStream = new DelimiterStream(new TextEncoder().encode(";"), { - * disposition: "suffix", - * }); - * ``` */ constructor( delimiter: Uint8Array, diff --git a/streams/limited_bytes_transform_stream.ts b/streams/limited_bytes_transform_stream.ts index dec3bd2fd..28e9ceaf2 100644 --- a/streams/limited_bytes_transform_stream.ts +++ b/streams/limited_bytes_transform_stream.ts @@ -101,77 +101,6 @@ export class LimitedBytesTransformStream * * @param size A size limit in bytes. * @param options Options for the stream. - * - * @example `size` is equal to the total byte length of the chunks - * ```ts - * import { LimitedBytesTransformStream } from "@std/streams/limited-bytes-transform-stream"; - * import { assertEquals } from "@std/assert"; - * - * const stream = ReadableStream.from(["1234", "5678"]); - * const transformed = stream.pipeThrough(new TextEncoderStream()).pipeThrough( - * new LimitedBytesTransformStream(8), - * ).pipeThrough(new TextDecoderStream()); - * - * assertEquals( - * await Array.fromAsync(transformed), - * ["1234", "5678"], - * ); - * ``` - * - * @example `size` is less than the total byte length of the chunks, and at the - * boundary of the chunks - * ```ts - * import { LimitedBytesTransformStream } from "@std/streams/limited-bytes-transform-stream"; - * import { assertEquals } from "@std/assert"; - * - * const stream = ReadableStream.from(["1234", "5678"]); - * const transformed = stream.pipeThrough(new TextEncoderStream()).pipeThrough( - * // `4` is the boundary of the chunks - * new LimitedBytesTransformStream(4), - * ).pipeThrough(new TextDecoderStream()); - * - * assertEquals( - * await Array.fromAsync(transformed), - * // The first chunk was read, but the second chunk was not - * ["1234"], - * ); - * ``` - * - * @example `size` is less than the total byte length of the chunks, and not at - * the boundary of the chunks - * ```ts - * import { LimitedBytesTransformStream } from "@std/streams/limited-bytes-transform-stream"; - * import { assertEquals } from "@std/assert"; - * - * const stream = ReadableStream.from(["1234", "5678"]); - * const transformed = stream.pipeThrough(new TextEncoderStream()).pipeThrough( - * // `5` is not the boundary of the chunks - * new LimitedBytesTransformStream(5), - * ).pipeThrough(new TextDecoderStream()); - * - * assertEquals( - * await Array.fromAsync(transformed), - * // The second chunk was not read because it would exceed the specified size - * ["1234"], - * ); - * ``` - * - * @example Throw error when the total byte length of the chunks exceeds the - * specified size - * - * ```ts - * import { LimitedBytesTransformStream } from "@std/streams/limited-bytes-transform-stream"; - * import { assertRejects } from "@std/assert"; - * - * const stream = ReadableStream.from(["1234", "5678"]); - * const transformed = stream.pipeThrough(new TextEncoderStream()).pipeThrough( - * new LimitedBytesTransformStream(5, { error: true }), - * ).pipeThrough(new TextDecoderStream()); - * - * await assertRejects(async () => { - * await Array.fromAsync(transformed); - * }, RangeError); - * ``` */ constructor( size: number, diff --git a/streams/limited_transform_stream.ts b/streams/limited_transform_stream.ts index d79364cc6..ddc2176ce 100644 --- a/streams/limited_transform_stream.ts +++ b/streams/limited_transform_stream.ts @@ -83,59 +83,6 @@ export class LimitedTransformStream extends TransformStream { * * @param size The maximum number of chunks to read. * @param options Options for the stream. - * - * @example `size` is equal to the total number of chunks - * ```ts - * import { LimitedTransformStream } from "@std/streams/limited-transform-stream"; - * import { assertEquals } from "@std/assert"; - * - * const stream = ReadableStream.from(["1234", "5678"]); - * const transformed = stream.pipeThrough( - * new LimitedTransformStream(2), - * ); - * - * // All chunks were read - * assertEquals( - * await Array.fromAsync(transformed), - * ["1234", "5678"], - * ); - * ``` - * - * @example `size` is less than the total number of chunks - * ```ts - * import { LimitedTransformStream } from "@std/streams/limited-transform-stream"; - * import { assertEquals } from "@std/assert"; - * - * const stream = ReadableStream.from(["1234", "5678"]); - * const transformed = stream.pipeThrough( - * new LimitedTransformStream(1), - * ); - * - * // Only the first chunk was read - * assertEquals( - * await Array.fromAsync(transformed), - * ["1234"], - * ); - * ``` - * - * @example Throw a {@linkcode RangeError} when the total number of chunks is - * about to exceed the specified limit - * - * Do this by setting `options.error` to `true`. - * - * ```ts - * import { LimitedTransformStream } from "@std/streams/limited-transform-stream"; - * import { assertRejects } from "@std/assert"; - * - * const stream = ReadableStream.from(["1234", "5678"]); - * const transformed = stream.pipeThrough( - * new LimitedTransformStream(1, { error: true }), - * ); - * - * await assertRejects(async () => { - * await Array.fromAsync(transformed); - * }, RangeError); - * ``` */ constructor( size: number, diff --git a/streams/text_delimiter_stream.ts b/streams/text_delimiter_stream.ts index 14efd8d4e..47f82d98b 100644 --- a/streams/text_delimiter_stream.ts +++ b/streams/text_delimiter_stream.ts @@ -67,22 +67,6 @@ export class TextDelimiterStream extends TransformStream { * * @param delimiter A delimiter to split the stream by. * @param options Options for the stream. - * - * @example Comma as a delimiter - * ```ts no-assert - * import { TextDelimiterStream } from "@std/streams/text-delimiter-stream"; - * - * const delimiterStream = new TextDelimiterStream(","); - * ``` - * - * @example Semicolon as a delimiter, and disposition set to `"suffix"` - * ```ts no-assert - * import { TextDelimiterStream } from "@std/streams/text-delimiter-stream"; - * - * const delimiterStream = new TextDelimiterStream(",", { - * disposition: "suffix", - * }); - * ``` */ constructor( delimiter: string, diff --git a/streams/text_line_stream.ts b/streams/text_line_stream.ts index 1666fb97e..aa2a239f1 100644 --- a/streams/text_line_stream.ts +++ b/streams/text_line_stream.ts @@ -71,37 +71,6 @@ export class TextLineStream extends TransformStream { * Constructs a new instance. * * @param options Options for the stream. - * - * @example No parameters - * ```ts - * import { TextLineStream } from "@std/streams/text-line-stream"; - * import { assertEquals } from "@std/assert"; - * - * const stream = ReadableStream.from([ - * "Hello,\n", - * "world!\n", - * ]).pipeThrough(new TextLineStream()); - * - * const lines = await Array.fromAsync(stream); - * - * assertEquals(lines, ["Hello,", "world!"]); - * ``` - * - * @example Allow splitting by `\r` - * - * ```ts - * import { TextLineStream } from "@std/streams/text-line-stream"; - * import { assertEquals } from "@std/assert"; - * - * const stream = ReadableStream.from([ - * "CR\rLF", - * "\nCRLF\r\ndone", - * ]).pipeThrough(new TextLineStream({ allowCR: true })); - * - * const lines = await Array.fromAsync(stream); - * - * assertEquals(lines, ["CR", "LF", "CRLF", "done"]); - * ``` */ constructor(options: TextLineStreamOptions = { allowCR: false }) { super({