Skip to content

Commit

Permalink
Use transferable TransformStream regardless of polyfill loaded after …
Browse files Browse the repository at this point in the history
…StreamSaver.js
  • Loading branch information
TexKiller committed Apr 1, 2019
1 parent 7a429f9 commit 4f52692
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions StreamSaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
location.hostname === 'localhost'
let iframe
let loaded
let transfarableSupport = false
let transferableTransformStream
let streamSaver = {
createWriteStream,
supported: false,
Expand Down Expand Up @@ -47,9 +47,9 @@
mc.port1.postMessage(readable, [readable])
mc.port1.close()
mc.port2.close()
transfarableSupport = readable.locked === true
transferableTransformStream = readable.locked === true ? TransformStream : 0
} catch (err) {
// Was first enabled in chrome v73
// Was first enabled in chrome v73 behind a flag
}

function iframePostMessage(url, args) {
Expand Down Expand Up @@ -165,7 +165,7 @@
if (secure) {
return iframePostMessage(streamSaver.mitm, args)
}
if (!hash && mozExtension && !transfarableSupport) {
if (!hash && mozExtension && !transferableTransformStream) {
hash = '#' + Math.random()
}
popup = load(streamSaver.mitm + hash, !hash, 1)
Expand All @@ -189,8 +189,8 @@
}
})

if (transfarableSupport) {
const ts = new TransformStream({
if (transferableTransformStream) {
const ts = new transferableTransformStream({
start () {
return new Promise(resolve =>
setTimeout(() => setupChannel(ts.readable).then(resolve))
Expand Down

0 comments on commit 4f52692

Please sign in to comment.