Skip to content

Commit

Permalink
fix: dedupe packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Jul 3, 2022
1 parent 4be86f5 commit 9ea33c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
21 changes: 8 additions & 13 deletions lib/file.js
Expand Up @@ -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')
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -49,6 +49,7 @@
"debug": "^4.3.4",
"end-of-stream": "^1.4.4",
"escape-html": "^1.0.3",
"fast-blob-stream": "^1.0.3",
"fs-chunk-store": "^2.0.5",
"immediate-chunk-store": "^2.2.0",
"load-ip-set": "^2.2.1",
Expand All @@ -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",
Expand Down

0 comments on commit 9ea33c2

Please sign in to comment.