From 34cb0db0de5af50d67f261b42013099eb1bf90f4 Mon Sep 17 00:00:00 2001 From: AykutSarac Date: Mon, 1 Aug 2022 09:22:52 +0300 Subject: [PATCH] refactor code --- src/utils/json-editor-parser.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/json-editor-parser.ts b/src/utils/json-editor-parser.ts index 5b8c375..c04e8ef 100644 --- a/src/utils/json-editor-parser.ts +++ b/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]) => {