rekwest 2.2.0 → 2.3.0
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.
- package/README.md +1 -1
- package/dist/formdata.js +11 -5
- package/package.json +1 -1
- package/src/formdata.mjs +17 -12
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ const file = new File(['bits'], 'file.dab');
|
|
|
85
85
|
const readable = Readable.from('bits');
|
|
86
86
|
|
|
87
87
|
const fd = new FormData({
|
|
88
|
-
aux: Date.now(), //
|
|
88
|
+
aux: Date.now(), // either [[key, value]], or kv sequenceable
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
fd.append('celestial', 'payload');
|
package/dist/formdata.js
CHANGED
|
@@ -87,11 +87,17 @@ class FormData {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
constructor(input) {
|
|
90
|
-
if (input
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
if (input === Object(input) && (input?.constructor === Object || Reflect.has(input, Symbol.iterator))) {
|
|
91
|
+
if (input.constructor !== Object) {
|
|
92
|
+
input = Array.from(input);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (Array.isArray(input)) {
|
|
96
|
+
if (!input.every(it => Array.isArray(it))) {
|
|
97
|
+
throw new TypeError(`Failed to construct '${this[Symbol.toStringTag]}': The provided value cannot be converted to a sequence.`);
|
|
98
|
+
} else if (!input.every(it => it.length === 2)) {
|
|
99
|
+
throw new TypeError(`Failed to construct '${this[Symbol.toStringTag]}': Sequence initializer must only contain pair elements.`);
|
|
100
|
+
}
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
if (input.constructor === Object) {
|
package/package.json
CHANGED
package/src/formdata.mjs
CHANGED
|
@@ -84,18 +84,23 @@ export class FormData {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
constructor(input) {
|
|
87
|
-
if (input
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
if (input === Object(input)
|
|
88
|
+
&& (input?.constructor === Object || Reflect.has(input, Symbol.iterator))) {
|
|
89
|
+
|
|
90
|
+
if (input.constructor !== Object) {
|
|
91
|
+
input = Array.from(input);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (Array.isArray(input)) {
|
|
95
|
+
if (!input.every((it) => Array.isArray(it))) {
|
|
96
|
+
throw new TypeError(`Failed to construct '${
|
|
97
|
+
this[Symbol.toStringTag]
|
|
98
|
+
}': The provided value cannot be converted to a sequence.`);
|
|
99
|
+
} else if (!input.every((it) => it.length === 2)) {
|
|
100
|
+
throw new TypeError(`Failed to construct '${
|
|
101
|
+
this[Symbol.toStringTag]
|
|
102
|
+
}': Sequence initializer must only contain pair elements.`);
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
if (input.constructor === Object) {
|