Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setStructure(
obj: any,
path: string[] | null,
structure: SaveStructureDef
) {
if (path && path.length > 0) {
// Collapse the intermediate paths.
for (let i = 1; i < path.length; i++) {
set(obj, [...path.slice(0, i), "$uiPathName"], false);
}
set(obj, path, structure);
} else {
// Use a one-value rootVariant to ensure we get a reference,
// to mantain recursive support.
Object.assign(obj, structure);
}
}
function setStructure(
obj: any,
path: string[] | null,
structure: SaveStructureDef
) {
if (path && path.length > 0) {
// Collapse the intermediate paths.
for (let i = 1; i < path.length; i++) {
set(obj, [...path.slice(0, i), "$uiPathName"], false);
}
set(obj, path, structure);
} else {
// Use a one-value rootVariant to ensure we get a reference,
// to mantain recursive support.
obj.$variants = [structure];
}
}
([path, value]) => {
const metaPath = [Symbols.meta, ...path]
const obj = set({}, metaPath, {
silent: token.silent,
source: token._source
})
set(obj, path, value)
return obj
}
),
if (typeof index !== "undefined") {
newArray = currentData.filter((item: any, itemIndex: number) => {
return itemIndex !== index;
});
} else {
newArray = currentData;
newArray.push(data);
}
location === "" ? (obj = newArray) : set(obj, location, newArray);
} else {
if (typeof data === "undefined") {
location === "" ? (obj = void 0) : unset(obj, location);
} else {
location === "" ? (obj = data) : set(obj, location, data);
}
}
if (isChildren) {
const children: ChildComponent | ChildComponent[] = get(obj, location);
if (Array.isArray(children) && children.length === 1) {
set(obj, location, children[0]);
}
}
this.props.onChange(obj);
};
onShowAllToggle(groupName) {
const { filterGroupsShowAll } = this.state;
const updatedShow = _.clone(filterGroupsShowAll);
_.set(updatedShow, groupName, !_.get(filterGroupsShowAll, groupName, false));
this.setState({ filterGroupsShowAll: updatedShow });
}
if (config.isArray) {
let newArray: any[];
if (typeof config.index !== "undefined") {
newArray = currentData.filter((item: any, itemIndex: number) => {
return itemIndex !== config.index;
});
} else {
newArray = currentData;
newArray.push(config.value);
}
config.dataLocation === ""
? (obj = newArray)
: set(obj, config.dataLocation, newArray);
} else {
if (typeof config.value === "undefined") {
config.dataLocation === ""
? (obj = void 0)
: unset(obj, config.dataLocation);
} else {
config.dataLocation === ""
? (obj = config.value)
: set(obj, config.dataLocation, config.value);
}
}
this.props.onChange(obj);
};
_.each(_.keys(activeFilters[field]), (key) =>
_.set(activeFilters, [field, key, 'active'], false),
);
.join(".");
const parentSourceData: unknown | unknown[] = get(data, parentSourceDataLocation);
let sourceDataLocationIndex: number = 0;
sourceDataLocationIndex = parseInt(
sourceDataLocationSegments[sourceDataLocationSegments.length - 1],
10
);
(parentSourceData as unknown[]).splice(
sourceDataLocationIndex + 1,
0,
cloneDeep(sourceData)
);
set(data as object, parentSourceDataLocation, parentSourceData as object[]);
}
setField = (path: string, v: any): void => {
const data = Object.assign({}, this.state.data);
_.set(data, path, v);
this.setState({data});
}
newArray = currentData;
newArray.push(config.value);
}
config.dataLocation === ""
? (obj = newArray)
: set(obj, config.dataLocation, newArray);
} else {
if (typeof config.value === "undefined") {
config.dataLocation === ""
? (obj = void 0)
: unset(obj, config.dataLocation);
} else {
config.dataLocation === ""
? (obj = config.value)
: set(obj, config.dataLocation, config.value);
}
}
this.props.onChange(obj);
};