Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCas <6506529+ThaUnknown@users.noreply.github.com>2022-09-02 23:19:41 +0300
committerGitHub <noreply@github.com>2022-09-02 23:19:41 +0300
commitf9bcb742ffc0053a37d61ea1955e51731bba2e27 (patch)
treea4cc52d86890caca78ed59b6f685031fbbea32f6
parentdb3bd901529bd0bb04c3d7b3193fd0aa490cc7af (diff)
parent94fcb7f54c2ebab88fcacca2e710e4bdd10516ef (diff)
Merge pull request #2347 from ThaUnknown/streamx-dep
fix: dedupe packages
-rw-r--r--lib/file.js21
-rw-r--r--package.json3
2 files changed, 9 insertions, 15 deletions
diff --git a/lib/file.js b/lib/file.js
index c5e5f1e..5e37581 100644
--- a/lib/file.js
+++ b/lib/file.js
@@ -2,8 +2,7 @@ const EventEmitter = require('events')
const { PassThrough } = require('stream')
const path = require('path')
const render = require('render-media')
-const streamToBlob = require('stream-to-blob')
-const streamToBlobURL = require('stream-to-blob-url')
+const { BlobWriteStream } = require('fast-blob-stream')
const streamToBuffer = require('stream-with-known-length-to-buffer')
const queueMicrotask = require('queue-microtask')
const rangeParser = require('range-parser')
@@ -123,20 +122,16 @@ class File extends EventEmitter {
getBlob (cb) {
if (typeof window === 'undefined') throw new Error('browser-only method')
- streamToBlob(this.createReadStream(), this._getMimeType())
- .then(
- blob => cb(null, blob),
- err => cb(err)
- )
+ const writeStream = new BlobWriteStream(blob => {
+ cb(null, blob)
+ }, { mimeType: this._getMimeType() })
+ this.createReadStream().pipe(writeStream)
}
getBlobURL (cb) {
- if (typeof window === 'undefined') throw new Error('browser-only method')
- streamToBlobURL(this.createReadStream(), this._getMimeType())
- .then(
- blobUrl => cb(null, blobUrl),
- err => cb(err)
- )
+ this.getBlob((_err, blob) => {
+ cb(null, URL.createObjectURL(blob))
+ })
}
appendTo (elem, opts, cb) {
diff --git a/package.json b/package.json
index 201ed2a..fd9fa03 100644
--- a/package.json
+++ b/package.json
@@ -49,6 +49,7 @@
"debug": "^4.3.4",
"end-of-stream": "^1.4.4",
"escape-html": "^1.0.3",
+ "fast-blob-stream": "^1.1.0",
"fs-chunk-store": "^2.0.5",
"immediate-chunk-store": "^2.2.0",
"load-ip-set": "^2.2.1",
@@ -71,8 +72,6 @@
"simple-peer": "^9.11.1",
"simple-sha1": "^3.1.0",
"speed-limiter": "^1.0.2",
- "stream-to-blob": "^2.0.1",
- "stream-to-blob-url": "^3.0.2",
"stream-with-known-length-to-buffer": "^1.0.4",
"throughput": "^1.0.1",
"torrent-discovery": "^9.4.13",