fix(core): update

This commit is contained in:
2023-07-12 19:40:41 +02:00
parent 61fcd5b992
commit a58c2881b9
21 changed files with 2181 additions and 28432 deletions

View File

@@ -1,21 +1,29 @@
export const toFlatObject = (objectArg: object) => {
const returnObject: {[key: string]: any} = {};
const extractLayer = (subObject: {[key: string]: any}, pathArg: string, loopProtection: object[]) => {
const returnObject: { [key: string]: any } = {};
const extractLayer = (
subObject: { [key: string]: any },
pathArg: string,
loopProtection: object[]
) => {
if (loopProtection.indexOf(subObject) > -1) {
return;
}
if (subObject)
for (const key of Object.keys(subObject)) {
let localPathArg = pathArg;
if (typeof subObject[ key ] === 'object' && !(subObject[ key ] instanceof Array)) {
if (typeof subObject[key] === 'object' && !(subObject[key] instanceof Array)) {
const newLoopbackArray = loopProtection.slice();
newLoopbackArray.push(subObject);
extractLayer(subObject[ key ], localPathArg ? localPathArg += `.${key}` : key, newLoopbackArray);
extractLayer(
subObject[key],
localPathArg ? (localPathArg += `.${key}`) : key,
newLoopbackArray
);
} else {
returnObject[localPathArg ? localPathArg += `.${key}` : key] = subObject[key];
returnObject[localPathArg ? (localPathArg += `.${key}`) : key] = subObject[key];
}
}
}
};
extractLayer(objectArg, '', []);
return returnObject;
}
};