How to use the lodash-es.set function in lodash-es

To help you get started, we’ve selected a few lodash-es examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RoboPhred / oni-duplicity / src / services / save-structure / structure / gameObjects / gameObjectTypes / utils.ts View on Github external
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);
  }
}
github RoboPhred / oni-duplicity / src / services / save-structure / structure / gameObjects / gameObjectTypes / index.ts View on Github external
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];
  }
}
github mlajtos / L1 / src / components / Interpreter / index.js View on Github external
([path, value]) => {
                        const metaPath = [Symbols.meta, ...path]
                        const obj = set({}, metaPath, {
                            silent: token.silent,
                            source: token._source
                        })

                        set(obj, path, value)
                        return obj
                    }
                ),
github microsoft / fast-dna / packages / fast-form-generator-react / src / form / form.tsx View on Github external
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);
    };
github openshift / console / frontend / public / components / utils / tile-view-page.jsx View on Github external
onShowAllToggle(groupName) {
    const { filterGroupsShowAll } = this.state;
    const updatedShow = _.clone(filterGroupsShowAll);
    _.set(updatedShow, groupName, !_.get(filterGroupsShowAll, groupName, false));
    this.setState({ filterGroupsShowAll: updatedShow });
  }
github microsoft / fast-dna / packages / fast-tooling-react / src / form / form.tsx View on Github external
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);
    };
github openshift / console / frontend / public / components / utils / tile-view-page.jsx View on Github external
_.each(_.keys(activeFilters[field]), (key) =>
      _.set(activeFilters, [field, key, 'active'], false),
    );
github microsoft / fast-dna / packages / fast-tooling-react / src / navigation / navigation.utilities.ts View on Github external
.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[]);
}
github openshift / console / frontend / public / components / silence.tsx View on Github external
setField = (path: string, v: any): void => {
    const data = Object.assign({}, this.state.data);
    _.set(data, path, v);
    this.setState({data});
  }
github microsoft / fast-dna / packages / fast-tooling-react / src / form / form.tsx View on Github external
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);
    };