use TransformStream if available
This commit is contained in:
parent
f32ebd913a
commit
38fd349d9b
|
@ -1,5 +1,5 @@
|
|||
import 'buffer';
|
||||
import { transform } from './streams';
|
||||
import { transformStream } from './streams';
|
||||
|
||||
const NONCE_LENGTH = 12;
|
||||
const TAG_LENGTH = 16;
|
||||
|
@ -353,9 +353,12 @@ export default class ECE {
|
|||
new BlobSlicer(this.input, this.rs, this.mode)
|
||||
);
|
||||
} else {
|
||||
inputStream = transform(this.input, new StreamSlicer(this.rs, this.mode));
|
||||
inputStream = transformStream(
|
||||
this.input,
|
||||
new StreamSlicer(this.rs, this.mode)
|
||||
);
|
||||
}
|
||||
return transform(
|
||||
return transformStream(
|
||||
inputStream,
|
||||
new ECETransformer(this.mode, this.key, this.rs, this.salt)
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Keychain from './keychain';
|
||||
import { downloadStream } from './api';
|
||||
import { transform } from './streams';
|
||||
import { transformStream } from './streams';
|
||||
import contentDisposition from 'content-disposition';
|
||||
|
||||
let noSave = false;
|
||||
|
@ -24,7 +24,7 @@ async function decryptStream(request) {
|
|||
|
||||
const body = await file.download.result;
|
||||
|
||||
const readStream = transform(body, {
|
||||
const readStream = transformStream(body, {
|
||||
transform: (chunk, controller) => {
|
||||
file.progress += chunk.length;
|
||||
controller.enqueue(chunk);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/* global ReadableStream */
|
||||
/* global ReadableStream TransformStream */
|
||||
|
||||
export function transform(readable, transformer) {
|
||||
export function transformStream(readable, transformer) {
|
||||
if (typeof TransformStream === 'function') {
|
||||
return readable.pipeThrough(new TransformStream(transformer));
|
||||
}
|
||||
const reader = readable.getReader();
|
||||
const tstream = new ReadableStream({
|
||||
start(controller) {
|
||||
|
|
Loading…
Reference in New Issue