@daysnap/utils 0.0.61 → 0.0.62
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/es/filterEmptyValue.js
CHANGED
|
@@ -2,6 +2,7 @@ import { isEmpty } from './isEmpty';
|
|
|
2
2
|
import { isEmptyArray } from './isEmptyArray';
|
|
3
3
|
import { isEmptyObject } from './isEmptyObject';
|
|
4
4
|
import { isFunction } from './isFunction';
|
|
5
|
+
import { isObject } from './isObject';
|
|
5
6
|
/**
|
|
6
7
|
* 过滤对象的 undefined null '' 属性,返回一个新对象
|
|
7
8
|
* @param obj 需要过滤的对象
|
|
@@ -15,7 +16,8 @@ export function filterEmptyValue(obj, expand = false) {
|
|
|
15
16
|
else {
|
|
16
17
|
if (!isEmpty(value)) {
|
|
17
18
|
if (expand) {
|
|
18
|
-
if (!isEmptyArray(value) &&
|
|
19
|
+
if (!isEmptyArray(value) &&
|
|
20
|
+
!(isObject(value) && isEmptyObject(value))) {
|
|
19
21
|
res[key] = value;
|
|
20
22
|
}
|
|
21
23
|
}
|
package/lib/filterEmptyValue.js
CHANGED
|
@@ -5,6 +5,7 @@ const isEmpty_1 = require("./isEmpty");
|
|
|
5
5
|
const isEmptyArray_1 = require("./isEmptyArray");
|
|
6
6
|
const isEmptyObject_1 = require("./isEmptyObject");
|
|
7
7
|
const isFunction_1 = require("./isFunction");
|
|
8
|
+
const isObject_1 = require("./isObject");
|
|
8
9
|
/**
|
|
9
10
|
* 过滤对象的 undefined null '' 属性,返回一个新对象
|
|
10
11
|
* @param obj 需要过滤的对象
|
|
@@ -18,7 +19,8 @@ function filterEmptyValue(obj, expand = false) {
|
|
|
18
19
|
else {
|
|
19
20
|
if (!(0, isEmpty_1.isEmpty)(value)) {
|
|
20
21
|
if (expand) {
|
|
21
|
-
if (!(0, isEmptyArray_1.isEmptyArray)(value) &&
|
|
22
|
+
if (!(0, isEmptyArray_1.isEmptyArray)(value) &&
|
|
23
|
+
!((0, isObject_1.isObject)(value) && (0, isEmptyObject_1.isEmptyObject)(value))) {
|
|
22
24
|
res[key] = value;
|
|
23
25
|
}
|
|
24
26
|
}
|