Move value nested iteration logic to stolendataentry class

This commit is contained in:
Kuba Orlik 2021-11-07 11:33:10 +01:00
parent 9f2712e0f9
commit ee96659aa0

View File

@ -75,8 +75,15 @@ export class StolenDataEntry {
} }
} }
getParsedValue(): string | Record<string, unknown> { getParsedValue(key_path: string): string | Record<string, unknown> {
return StolenDataEntry.parseValue(this.value); let object = StolenDataEntry.parseValue(this.value);
console.log("key_path", key_path);
for (const key of key_path.split(".")) {
if (key === "") continue;
console.log(key, object[key]);
object = StolenDataEntry.parseValue(object[key]);
}
return object;
} }
addMarkedValue(key: string) { addMarkedValue(key: string) {
@ -118,8 +125,10 @@ export class MergedStolenDataEntry {
return Array.from(new Set(this.entries.map((e) => e.value))); return Array.from(new Set(this.entries.map((e) => e.value)));
} }
getParsedValues() { getParsedValues(key_path: string) {
return Array.from(new Set(this.entries.map((e) => e.getParsedValue()))); return Array.from(
new Set(this.entries.map((e) => e.getParsedValue(key_path)))
);
} }
addMarkedValue(key: string) { addMarkedValue(key: string) {