refactor: remove getNonNullValues, replace with _.ominBy and _.isNull (lodash)

ref: https://stackoverflow.com/a/70554734/11408375
This commit is contained in:
HD
2022-06-28 10:31:19 +08:00
parent ab5f9e6c07
commit 6bf64e38fc
3 changed files with 7 additions and 13 deletions
+1 -9
View File
@@ -20,15 +20,6 @@ export const isTreatAsImage = (file: File) => {
return false;
};
export const getNonNullValues = (obj, whiteList = ["log_id"]) => {
const tmp = {};
Object.keys(obj).forEach((k) => {
if (!whiteList.includes(k) && obj[k] !== null) {
tmp[k] = obj[k];
}
});
return tmp;
};
export function getDefaultSize(size = null, min = 480) {
if (!size) return { width: 0, height: 0 };
const { width: oWidth, height: oHeight } = size;
@@ -48,6 +39,7 @@ export function getDefaultSize(size = null, min = 480) {
}
return { width: dWidth, height: dHeight };
}
export function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return "0 Bytes";