From 87ea373e07e96ff23fc081ed2ceb994a1753a993 Mon Sep 17 00:00:00 2001 From: Gabriel Hernandez Date: Sun, 3 Nov 2024 19:10:52 +0000 Subject: [PATCH] fix: add `TransformStream` (#20) Co-authored-by: Artem Zakharchenko --- README.md | 1 + index.js | 1 + index.test.js | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index f6e4017..0576884 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ This project "fixes" the following global APIs, overriding whichever polyfills t - `URL` - `URLSearchParams` - `BroadcastChannel` +- `TransformStream` ## Getting started diff --git a/index.js b/index.js index b1f63d9..5251ae5 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,7 @@ class FixedJSDOMEnvironment extends JSDOMEnvironment { this.global.URLSearchParams = URLSearchParams this.global.BroadcastChannel = BroadcastChannel + this.global.TransformStream = TransformStream } } diff --git a/index.test.js b/index.test.js index 41cacc5..2d48f46 100644 --- a/index.test.js +++ b/index.test.js @@ -2,6 +2,7 @@ const { URL: BuiltinURL } = require('node:url') const { BroadcastChannel: BuiltinBroadcastChannel, } = require('node:worker_threads') +const { TransformStream: BuiltinTransformStream } = require('node:stream/web') test('exposes "Blob"', async () => { expect(globalThis).toHaveProperty('Blob') @@ -163,3 +164,9 @@ test('exposes "BroadcastChannel"', () => { expect(channel).toBeInstanceOf(BuiltinBroadcastChannel) channel.unref() }) + +test('exposes "TransformStream"', () => { + expect(globalThis).toHaveProperty('TransformStream') + const channel = new TransformStream() + expect(channel).toBeInstanceOf(BuiltinTransformStream) +})