File tree 1 file changed +18
-11
lines changed
1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -197,11 +197,25 @@ function isEmptyValue(value) {
197
197
return true;
198
198
}
199
199
200
- if (Array.isArray(value) && value.length === 0) {
200
+ if (Array.isArray(value)) {
201
+ for (var element of value) {
202
+ if (!isEmptyValue(element)) {
203
+ // the array has at least one non-empty element
204
+ return false;
205
+ }
206
+ }
207
+ // the array has no non-empty elements
201
208
return true;
202
209
}
203
210
204
- if (typeof value === 'object' && Object.values(value).length === 0) {
211
+ if (typeof value === 'object') {
212
+ for (var childValue of Object.values(value)) {
213
+ if (!isEmptyValue(childValue)) {
214
+ // the object has at least one non-empty property
215
+ return false;
216
+ }
217
+ }
218
+ // the object has no non-empty property
205
219
return true;
206
220
}
207
221
@@ -213,15 +227,8 @@ function emptyValueReplacer(_, value) {
213
227
return undefined;
214
228
}
215
229
216
- if (typeof value === 'object') {
217
- for (var childValue of Object.values(value)) {
218
- if (!isEmptyValue(childValue)) {
219
- // the object has at least one non-empty property
220
- return value;
221
- }
222
- }
223
- // the object has no non-empty property
224
- return undefined;
230
+ if (Array.isArray(value)) {
231
+ return value.filter(e => !isEmptyValue(e));
225
232
}
226
233
227
234
return value;
You can’t perform that action at this time.
0 commit comments