diff options
author | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
commit | 3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch) | |
tree | 75be5fba4368472fb11c8015aee026b2b9a71888 /together/node_modules/formidable/src/VolatileFile.js | |
parent | 8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff) | |
download | pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2 pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip |
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'together/node_modules/formidable/src/VolatileFile.js')
-rw-r--r-- | together/node_modules/formidable/src/VolatileFile.js | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/together/node_modules/formidable/src/VolatileFile.js b/together/node_modules/formidable/src/VolatileFile.js deleted file mode 100644 index 01af428..0000000 --- a/together/node_modules/formidable/src/VolatileFile.js +++ /dev/null @@ -1,82 +0,0 @@ -/* eslint-disable no-underscore-dangle */ - -'use strict'; - -const crypto = require('crypto'); -const { EventEmitter } = require('events'); - -class VolatileFile extends EventEmitter { - constructor({ filepath, newFilename, originalFilename, mimetype, hashAlgorithm, createFileWriteStream }) { - super(); - - this.lastModifiedDate = null; - Object.assign(this, { filepath, newFilename, originalFilename, mimetype, hashAlgorithm, createFileWriteStream }); - - this.size = 0; - this._writeStream = null; - - if (typeof this.hashAlgorithm === 'string') { - this.hash = crypto.createHash(this.hashAlgorithm); - } else { - this.hash = null; - } - } - - open() { - this._writeStream = this.createFileWriteStream(this); - this._writeStream.on('error', (err) => { - this.emit('error', err); - }); - } - - destroy() { - this._writeStream.destroy(); - } - - toJSON() { - const json = { - size: this.size, - newFilename: this.newFilename, - length: this.length, - originalFilename: this.originalFilename, - mimetype: this.mimetype, - }; - if (this.hash && this.hash !== '') { - json.hash = this.hash; - } - return json; - } - - toString() { - return `VolatileFile: ${this.originalFilename}`; - } - - write(buffer, cb) { - if (this.hash) { - this.hash.update(buffer); - } - - if (this._writeStream.closed || this._writeStream.destroyed) { - cb(); - return; - } - - this._writeStream.write(buffer, () => { - this.size += buffer.length; - this.emit('progress', this.size); - cb(); - }); - } - - end(cb) { - if (this.hash) { - this.hash = this.hash.digest('hex'); - } - this._writeStream.end(() => { - this.emit('end'); - cb(); - }); - } -} - -module.exports = VolatileFile; |