Skip to content

Commit

Permalink
fix: add TransformStream (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Artem Zakharchenko <[email protected]>
  • Loading branch information
ghernandez345 and kettanaito authored Nov 3, 2024
1 parent a65ea67 commit 87ea373
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This project "fixes" the following global APIs, overriding whichever polyfills t
- `URL`
- `URLSearchParams`
- `BroadcastChannel`
- `TransformStream`

## Getting started

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FixedJSDOMEnvironment extends JSDOMEnvironment {
this.global.URLSearchParams = URLSearchParams

this.global.BroadcastChannel = BroadcastChannel
this.global.TransformStream = TransformStream
}
}

Expand Down
7 changes: 7 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
})

0 comments on commit 87ea373

Please sign in to comment.