@alextheman/utility 2.12.0 → 2.12.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.
package/dist/index.cjs CHANGED
@@ -176,14 +176,25 @@ function createFormData(data, options = { arrayResolution: "stringify", nullable
176
176
  } else if (value === void 0 || value === null) {
177
177
  resolveNullables(key, value, options);
178
178
  } else if (typeof value === "object") {
179
- if (Array.isArray(value) && (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple")) {
180
- for (const item of value) {
181
- if ((typeof item === "object" || !item) && !(item instanceof Blob)) {
182
- throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
179
+ if (Array.isArray(value)) {
180
+ if (value.some((item) => {
181
+ return item instanceof Blob;
182
+ }) && (options.arrayResolution === "stringify" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "stringify")) {
183
+ throw new TypeError("CANNOT_STRINGIFY_BLOB");
184
+ }
185
+ if (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple") {
186
+ for (const item of value) {
187
+ if ((typeof item === "object" || !item) && !(item instanceof Blob)) {
188
+ throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
189
+ }
190
+ if (item instanceof Blob) {
191
+ formData.append(String(key), item);
192
+ } else {
193
+ formData.append(String(key), String(item));
194
+ }
183
195
  }
184
- formData.append(String(key), String(item));
196
+ continue;
185
197
  }
186
- continue;
187
198
  }
188
199
  formData.append(String(key), JSON.stringify(value));
189
200
  } else {
package/dist/index.js CHANGED
@@ -117,14 +117,25 @@ function createFormData(data, options = { arrayResolution: "stringify", nullable
117
117
  } else if (value === void 0 || value === null) {
118
118
  resolveNullables(key, value, options);
119
119
  } else if (typeof value === "object") {
120
- if (Array.isArray(value) && (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple")) {
121
- for (const item of value) {
122
- if ((typeof item === "object" || !item) && !(item instanceof Blob)) {
123
- throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
120
+ if (Array.isArray(value)) {
121
+ if (value.some((item) => {
122
+ return item instanceof Blob;
123
+ }) && (options.arrayResolution === "stringify" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "stringify")) {
124
+ throw new TypeError("CANNOT_STRINGIFY_BLOB");
125
+ }
126
+ if (options.arrayResolution === "multiple" || typeof options.arrayResolution === "object" && options.arrayResolution[key] === "multiple") {
127
+ for (const item of value) {
128
+ if ((typeof item === "object" || !item) && !(item instanceof Blob)) {
129
+ throw new TypeError("NON_PRIMITIVE_ARRAY_ITEMS_FOUND");
130
+ }
131
+ if (item instanceof Blob) {
132
+ formData.append(String(key), item);
133
+ } else {
134
+ formData.append(String(key), String(item));
135
+ }
124
136
  }
125
- formData.append(String(key), String(item));
137
+ continue;
126
138
  }
127
- continue;
128
139
  }
129
140
  formData.append(String(key), JSON.stringify(value));
130
141
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Helpful utility functions",
5
5
  "license": "ISC",
6
6
  "author": "alextheman",