WIP on shimming streams in firefox

This commit is contained in:
Danny Coates 2018-07-13 17:05:19 -07:00
parent 23c347175a
commit f4f8332f96
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
5 changed files with 46 additions and 11 deletions

25
app/transformStream.js Normal file
View file

@ -0,0 +1,25 @@
/* global TransformStream */
import { createReadableStreamWrapper } from '@mattiasbuelens/web-streams-adapter';
import { TransformStream as TransformStreamPony } from 'web-streams-ponyfill';
const toNative = createReadableStreamWrapper(ReadableStream);
class TransformStreamLocal {
constructor(transformer) {
this.stream = new TransformStreamPony(transformer);
this.local = true;
}
get nativeReadable() {
return toNative(this.stream.readable);
}
get readable() {
return this.stream.readable;
}
get writable() {
return this.stream.writable;
}
}
export default (typeof TransformStream === 'function'
? TransformStream
: TransformStreamLocal);