formdata-node
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -18,2 +18,4 @@ "use strict"; | ||
var _from = _interopRequireDefault(require("@babel/runtime/core-js/array/from")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -120,5 +122,5 @@ | ||
(0, _defineProperty2.default)(this, "set", (name, value, filename) => this.__setField(name, value, filename)); | ||
(0, _defineProperty2.default)(this, "has", name => this.__contents.has(name)); | ||
(0, _defineProperty2.default)(this, "has", name => this.__content.has(name)); | ||
(0, _defineProperty2.default)(this, "get", name => { | ||
const field = this.__contents.get(name); | ||
const field = this.__content.get(name); | ||
@@ -132,15 +134,7 @@ if (!field) { | ||
(0, _defineProperty2.default)(this, "getAll", name => { | ||
const res = []; | ||
const field = this.__content.get(name); | ||
const field = this.__contents.get(name); | ||
if (field) { | ||
for (const value of field.values) { | ||
res.push(value); | ||
} | ||
} | ||
return res; | ||
return field ? (0, _from.default)(field.values) : []; | ||
}); | ||
(0, _defineProperty2.default)(this, "delete", name => void this.__contents.delete(name)); | ||
(0, _defineProperty2.default)(this, "delete", name => void this.__content.delete(name)); | ||
(0, _defineProperty2.default)(this, "pipe", (dest, options) => this.__stream.pipe(dest, options)); | ||
@@ -157,4 +151,3 @@ (0, _defineProperty2.default)(this, "forEach", (fn, ctx = null) => { | ||
this.__boundary = (0, _concat.default)(["NodeJSFormDataStream", (0, _boundary.default)()]); | ||
this.__contents = new _map.default(); | ||
this.__entries = this.__contents.entries(); | ||
this.__content = new _map.default(); | ||
this.__curr = this.__getField(); | ||
@@ -203,23 +196,9 @@ const read = this.__read; | ||
return (0, _wrapAsyncGenerator2.default)(function* () { | ||
while (true) { | ||
const curr = _this.__entries.next(); // Send a footer when iterator ends | ||
for (const [name, { | ||
values, | ||
filename | ||
}] of _this.__content) { | ||
// Set field header | ||
yield _this.__getHeader(name, filename); | ||
if (curr.done === true) { | ||
yield _this.__getFooter(); // In some cases I can't just return footer to stop iterator, | ||
// so this might help. | ||
// According to tests, it happens only Node 8.x | ||
// eslint-disable-next-line max-len | ||
// @see: https://travis-ci.org/octet-stream/apollo-link-form-data/jobs/465480482#L485-L490 | ||
return; | ||
} | ||
const [name, { | ||
values, | ||
filename | ||
}] = curr.value; // Set field header | ||
yield _this.__getHeader(name, filename); // Set the field body | ||
for (const value of values) { | ||
@@ -236,3 +215,6 @@ if ((0, _isReadable.default)(value)) { | ||
yield _this.__carriage; | ||
} | ||
} // Add a footer when all fields ended | ||
yield _this.__getFooter(); | ||
})(); | ||
@@ -290,7 +272,7 @@ } | ||
const field = this.__contents.get(name); // Set a new field if given name is not exists | ||
const field = this.__content.get(name); // Set a new field if given name is not exists | ||
if (!field) { | ||
return void this.__contents.set(name, { | ||
return void this.__content.set(name, { | ||
append, | ||
@@ -304,3 +286,3 @@ filename, | ||
if (!append) { | ||
return void this.__contents.set(name, { | ||
return void this.__content.set(name, { | ||
append, | ||
@@ -320,3 +302,3 @@ filename, | ||
this.__contents.set(name, field); | ||
this.__content.set(name, field); | ||
} | ||
@@ -391,3 +373,3 @@ /** | ||
*keys() { | ||
for (const key of this.__contents.keys()) { | ||
for (const key of this.__content.keys()) { | ||
yield key; | ||
@@ -425,2 +407,5 @@ } | ||
/** | ||
* @return {IterableIterator<[string, any]>} | ||
*/ | ||
[_Symbol$iterator]() { | ||
@@ -440,3 +425,7 @@ return this.entries(); | ||
[_Symbol$asyncIterator]() { | ||
return new _StreamIterator.default(this.__stream); | ||
if ((0, _isFunction.default)(this.stream[_symbol.default.asyncIterator])) { | ||
return this.stream[_symbol.default.asyncIterator](); | ||
} | ||
return new _StreamIterator.default(this.stream); | ||
} | ||
@@ -443,0 +432,0 @@ |
{ | ||
"name": "formdata-node", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "FormData implementation for Node.js. Built over Readable stream and async generators. Can be used to communicate between servers with multipart/form-data format.", | ||
@@ -52,14 +52,14 @@ "repository": "octet-stream/form-data", | ||
"codecov": "3.2.0", | ||
"eslint": "5.13.0", | ||
"eslint": "5.14.1", | ||
"eslint-plugin-ava": "5.1.1", | ||
"husky": "1.3.1", | ||
"lint-staged": "^8.1.3", | ||
"lint-staged": "8.1.4", | ||
"lodash.isplainobject": "4.0.6", | ||
"nyc": "13.2.0", | ||
"nyc": "13.3.0", | ||
"promise-fs": "2.0.1", | ||
"proxyquire": "2.1.0", | ||
"rimraf": "2.6.3", | ||
"sinon": "7.2.3", | ||
"sinon": "7.2.4", | ||
"supertest": "3.4.2", | ||
"then-busboy": "3.0.0" | ||
"then-busboy": "4.2.0" | ||
}, | ||
@@ -69,5 +69,5 @@ "dependencies": { | ||
"@octetstream/invariant": "1.2.0", | ||
"mime-types": "2.1.21", | ||
"mime-types": "2.1.22", | ||
"nanoid": "2.0.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44989
995
+ Addedmime-db@1.38.0(transitive)
+ Addedmime-types@2.1.22(transitive)
- Removedmime-db@1.37.0(transitive)
- Removedmime-types@2.1.21(transitive)
Updatedmime-types@2.1.22