소스 검색

refactor code

AykutSarac 2 년 전
부모
커밋
34cb0db0de
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      src/utils/json-editor-parser.ts

+ 5 - 3
src/utils/json-editor-parser.ts

@@ -1,9 +1,11 @@
 import toast from "react-hot-toast";
 
 const filterChild = ([k, v]) => {
-  const notNull = v !== null;
-  const isArray = Array.isArray(v) ? !!v.length : typeof v === "object";
-  return notNull && isArray;
+  const isNull = v === null;
+  const isArray = Array.isArray(v) && v.length;
+  const isObject = v instanceof Object;
+
+  return !isNull && (isArray || isObject);
 };
 
 const filterValues = ([k, v]) => {