Open
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Hello there, i just wrote simple polyfil for BunJS and drizzle-kit studio.
LINE: 88605 -> 88643
import zlib from 'node:zlib';
function polyfilCompressionStream() {
// @bun
const make = (ctx, handle) => Object.assign(ctx, {
writable: new WritableStream({
write: chunk => handle.write(chunk),
close: () => handle.end()
}),
readable: new ReadableStream({
type: 'bytes',
start (ctrl) {
handle.on('data', chunk => ctrl.enqueue(chunk))
handle.once('end', () => ctrl.close())
}
})
})
globalThis.CompressionStream ??= class CompressionStream {
constructor(format) {
make(this, format === 'deflate' ? zlib.createDeflate() :
format === 'gzip' ? zlib.createGzip() : zlib.createDeflateRaw())
}
}
globalThis.DecompressionStream ??= class DecompressionStream {
constructor(format) {
make(this, format === 'deflate' ? zlib.createInflate() :
format === 'gzip' ? zlib.createGunzip() :
zlib.createInflateRaw())
}
}
}
if (typeof globalThis.CompressionStream === 'undefined') {
polyfilCompressionStream();
}