@poppinss/multiparty 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/HISTORY.md +5 -0
  2. package/index.js +28 -1
  3. package/package.json +8 -4
package/HISTORY.md CHANGED
@@ -1,6 +1,11 @@
1
1
  unreleased
2
2
  ==========
3
3
 
4
+ * Fix form parsing when no `part` event listener added
5
+
6
+ 4.2.3 / 2022-01-20
7
+ ==================
8
+
4
9
  * Fix handling of unquoted values in `Content-Disposition`
5
10
  * deps: http-errors@~1.8.1
6
11
  - deps: toidentifier@1.0.1
package/index.js CHANGED
@@ -672,7 +672,14 @@ function handlePart(self, partStream) {
672
672
  endFlush(self);
673
673
  });
674
674
  emitAndReleaseHold(function() {
675
- self.emit('part', partStream);
675
+ if (hasListeners(self, 'part')) {
676
+ self.emit('part', partStream)
677
+ } else {
678
+ partStream.on('error', function (err) {
679
+ self.handleError(err)
680
+ })
681
+ partStream.resume()
682
+ }
676
683
  });
677
684
  }
678
685
 
@@ -754,6 +761,26 @@ function handleField(self, fieldStream) {
754
761
  });
755
762
  }
756
763
 
764
+ /**
765
+ * Determine if emitter has listeners of a given type.
766
+ *
767
+ * The way to do this check is done three different ways in Node.js >= 0.10
768
+ * so this consolidates them into a minimal set using instance methods.
769
+ *
770
+ * @param {EventEmitter} emitter
771
+ * @param {string} type
772
+ * @returns {boolean}
773
+ * @private
774
+ */
775
+
776
+ function hasListeners (emitter, type) {
777
+ var count = typeof emitter.listenerCount !== 'function'
778
+ ? emitter.listeners(type).length
779
+ : emitter.listenerCount(type)
780
+
781
+ return count > 0
782
+ }
783
+
757
784
  function clearPartVars(self) {
758
785
  self.partHeaders = {};
759
786
  self.partName = null;
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@poppinss/multiparty",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "multipart/form-data parser which supports streaming",
5
5
  "main": "index.js",
6
+ "contributors": [
7
+ "Douglas Christopher Wilson <doug@somethingdoug.com>",
8
+ "Felix Geisendörfer <felix@debuggable.com>"
9
+ ],
6
10
  "license": "MIT",
7
11
  "keywords": [
8
12
  "file",
@@ -17,15 +21,15 @@
17
21
  "uid-safe": "2.1.5"
18
22
  },
19
23
  "devDependencies": {
20
- "eslint": "^8.5.0",
24
+ "eslint": "^8.9.0",
21
25
  "eslint-plugin-markdown": "2.2.1",
22
26
  "mkdirp": "^1.0.4",
23
- "mocha": "^9.1.3",
27
+ "mocha": "^9.2.1",
24
28
  "nyc": "15.1.0",
25
29
  "pend": "1.2.0",
26
30
  "require-all": "3.0.0",
27
31
  "rimraf": "^3.0.2",
28
- "superagent": "^6.1.0"
32
+ "superagent": "^7.1.1"
29
33
  },
30
34
  "files": [
31
35
  "HISTORY.md",