diff --git a/src/utils/stream.ts b/src/utils/stream.ts index 86f3caa..4fb9750 100644 --- a/src/utils/stream.ts +++ b/src/utils/stream.ts @@ -1,5 +1,5 @@ // https://github.com/oven-sh/bun/issues/5648#issuecomment-1824093837 -export class TextDecoderStream extends TransformStream { +class TextDecoderStreamPolyfill extends TransformStream { readonly encoding: string; readonly fatal: boolean; readonly ignoreBOM: boolean; @@ -28,6 +28,10 @@ export class TextDecoderStream extends TransformStream { } } +const TDS = typeof TextDecoderStream !== 'undefined' ? TextDecoderStream : TextDecoderStreamPolyfill; + +export { TDS as TextDecoderStream }; + export class LineBreakStream extends TransformStream { constructor() { let current = '';