JSFiddle - React, Tailwind, and code Playground
by irinablue
JavaScript
function deepIterator (target) {
if (typeof target === 'object') {
//console.log('target', target);
for (const key in target) {
if (Array.isArray(target[key])) {
//console.log('target', target[key]);
//const dataWithoutDraft = target[key].filter(item => item?.k && typeof item.k === 'string' && !item.k.includes('[DRAFT]'));
//console.log('dataWithoutDraft', target[key], dataWithoutDraft);
_.remove(target[key], function(item) {
return item?.k && typeof item.k === 'string' && item.k.includes('[DRAFT]');
});
}
deepIterator(target[key]);
}
}
}
const data_imp = {
"ce": {
"rn": "cookies_popup",
"ri": 27,
"en": "cookies_popup",
"ei": 129,
"ebi": 129,
"t": "block"
},
"se": {
"s": ".popup-choose-cookies"
},
"gv": [
{
"k": "3",
"v": null
},
{
"k": "15",
"v": "0"
},
{
"k": "18",
"v": "0"
},
{
"k": "19",
"v": "0"
},
{
"k": "31",
"v": "0"
},
{
"k": "34",
"v": "691590"
},
{
"k": "36",
"v": "0.34978104"
},
{
"k": "37",
"v": "main"
},
{
"k": "42",
"v": null
},
{
"k": "43",
"v": "bskidcxvOCnxg73T4i3wtgkYXmNN79Il2wNmyPwyr4c07"
},
{
"k": "48",
"v": null
},
{
"k": "50",
"v": null
},
{
"k": "58",
"v": "false"
},
{
"k": "[DRAFT] 202",
"v": "category"
}
],
"imp": {
"l": [
...