From 465bdbd76aec9f7a63dc47c11729e7d60f0497e8 Mon Sep 17 00:00:00 2001 From: Majid Q Date: Sat, 28 Sep 2024 17:35:20 +1000 Subject: [PATCH] start root depth with 0 --- src/json.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/json.js b/src/json.js index 5b6834c..3822f64 100644 --- a/src/json.js +++ b/src/json.js @@ -111,7 +111,7 @@ const createObject = (obj, depth, currentKey, opts = {}) => { const constructorName = obj.constructor.name; if (NO_RESOLUTION_CLASS_LIST.some(f => f === constructorName)) { if (TYPED_ARRAY_NAMES.some(f => f === constructorName)) { - return createArray(obj, 1, currentKey, opts); + return createArray(obj, 0, currentKey, opts); } return obj; } @@ -174,10 +174,10 @@ const json = (val, opts = {}) => { } if (isArrayType(val)) { - return createArray(val, 1, '', opts); + return createArray(val, 0, '', opts); } - return createObject(val, 1, '', opts); + return createObject(val, 0, '', opts); }; /**