How to use the lodash-es.cloneDeep 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 microsoft / fast-dna / packages / fast-permutator / src / utilities / resolve-dependencies.js View on Github external
schemaBaseClone.required = schemaBaseClone.required.concat(
                            schemaBaseClone.dependencies[dependencyKey]
                        );
                    }
                }
            }
        }

        // split schemas up based on optional dependencies
        for (let dependencyKey of dependencyKeys) {
            let isRequired =
                Array.isArray(schema.required) &&
                schema.required.indexOf(dependencyKey) !== -1;

            if (!isRequired) {
                let optionalSchemaClone = clone(schemaBaseClone);
                optionalSchemaClone.required.push(dependencyKey);
                optionalSchemaClone.required = optionalSchemaClone.required.concat(
                    optionalSchemaClone.dependencies[dependencyKey]
                );
                schemasPermutated.push(optionalSchemaClone);
                delete schemaBaseClone.properties[dependencyKey];
            }
        }

        // the base schema with no options
        schemasPermutated.push(schemaBaseClone);
    }

    return schemasPermutated;
};
github microsoft / fast-dna / packages / fast-tooling-react / src / form / utilities / form.tsx View on Github external
function removeUndefinedKeys(data: any): any {
    const clonedData: any = cloneDeep(data);

    if (clonedData !== undefined) {
        Object.keys(clonedData).forEach((key: string) => {
            if (typeof clonedData[key] === "undefined") {
                // if this is a child we may be getting undefined default props, remove these
                delete clonedData[key];
            }
        });
    }

    return clonedData;
}
github openshift / console / frontend / __tests__ / components / operator-lifecycle-manager / create-crd-yaml.spec.tsx View on Github external
it('renders YAML editor component', () => {
    wrapper = wrapper.setProps({ClusterServiceVersion: {loaded: true, data: _.cloneDeep(testClusterServiceVersion)}} as any);

    expect(wrapper.find(Firehose).childAt(0).dive().find(CreateYAML).exists()).toBe(true);
  });
github Sunbird-Ed / SunbirdEd-portal / src / app / client / src / app / modules / learn / components / batch / batch-details / batch-details.component.ts View on Github external
getAllBatchDetails() {
    this.showBatchList = false;
    this.showError = false;
    this.batchList = [];
    const searchParams: any = {
      filters: {
        status: this.batchStatus.toString(),
        courseId: this.courseId
      },
      offset: 0,
      sort_by: { createdDate: 'desc' }
    };
    const searchParamsCreator =  _.cloneDeep(searchParams);
    const searchParamsMentor =  _.cloneDeep(searchParams);

    if (this.courseMentor) {
      searchParamsCreator.filters.createdBy = this.userService.userid;
      searchParamsMentor.filters.mentors = [this.userService.userid];
      combineLatest(
        this.courseBatchService.getAllBatchDetails(searchParamsCreator),
        this.courseBatchService.getAllBatchDetails(searchParamsMentor),
      ).pipe(takeUntil(this.unsubscribe))
       .subscribe((data) => {
           this.batchList = _.union(data[0].result.response.content, data[1].result.response.content);
           if (this.batchList.length > 0) {
             this.fetchUserDetails();
           } else {
             this.showBatchList = true;
           }
        }, (err) => {
github openshift / console / frontend / public / components / utils / tile-view-page.jsx View on Github external
onFilterChange(filterType, id, value) {
    const { activeFilters, selectedCategoryId, categories } = this.state;

    if (filterType === 'keyword') {
      updateURLParams(KEYWORD_URL_PARAM, `${value}`);
    } else {
      const groupFilter = _.cloneDeep(activeFilters[filterType]);
      _.set(groupFilter, [id, 'active'], value);
      updateURLParams(filterType, getFilterSearchParam(groupFilter));
    }

    const updatedFilters = updateActiveFilters(activeFilters, filterType, id, value);

    this.updateMountedState(this.getUpdatedState(categories, selectedCategoryId, updatedFilters));
  }
github bitshares / bitshares-ui / app / components / Exchange / DepthHighChart.jsx View on Github external
settleColor,
            settleFillColor,
            bidColor,
            bidFillColor,
            askColor,
            askFillColor,
            axisLineColor
        } = this._getThemeColors();

        let {name: baseSymbol, prefix: basePrefix} = utils.replaceName(base);
        let {name: quoteSymbol, prefix: quotePrefix} = utils.replaceName(quote);
        baseSymbol = (basePrefix || "") + baseSymbol;
        quoteSymbol = (quotePrefix || "") + quoteSymbol;

        let flatBids = cloneDeep(flat_bids),
            flatAsks = cloneDeep(flat_asks),
            flatCalls = cloneDeep(flat_calls),
            flatSettles = cloneDeep(flat_settles);

        let config = {
            chart: {
                type: "area",
                backgroundColor: "rgba(255, 0, 0, 0)",
                spacing: [10, 0, 5, 0]
            },
            title: {
                text: null
            },
            credits: {
                enabled: false
            },
            legend: {
github metaspace2020 / metaspace / metaspace / webapp / src / modules / MetadataEditor / MetadataEditor.vue View on Github external
data() {
    return {
      value: null,
      schema: null,
      loadingPromise: null,
      localErrors: {},
      molDBOptions: [],
      possibleAdducts: {},
      metaspaceOptions: cloneDeep(defaultMetaspaceOptions),
      submitter: null,
      initialValue: null,
      initialMetaspaceOptions: null,
    }
  },
github EndyKaufman / ngx-dynamic-form-builder / libs / ngx-dynamic-form-builder / src / shared / utils / dynamic-form-group.ts View on Github external
validate(externalErrors?: IShortValidationErrors, validatorOptions?: ValidatorOptions) {
        if (externalErrors === undefined) {
            externalErrors = cloneDeep(this.externalErrors);
        }
        if (validatorOptions === undefined) {
            validatorOptions = cloneDeep(this.validatorOptions);
        }
        if (!externalErrors) {
            externalErrors = {};
        }
        const errors = validateSync(this.object, validatorOptions);
        const transformedErrors = this.transformValidationErrors(errors);
        const allErrors = this.mergeErrors(externalErrors, transformedErrors);
        this.markAsInvalidForExternalErrors(externalErrors, this.controls);
        this.customValidateErrors.next(allErrors);
    }
    private markAsInvalidForExternalErrors(errors: IShortValidationErrors, controls: {
github Sunbird-Ed / SunbirdEd-portal / src / app / client / src / app / modules / learn / services / course-batch / course-batch.service.ts View on Github external
getUserList(requestParam: SearchParam = {}): Observable {
    if (_.isEmpty(requestParam) && this.defaultUserList) {
      return observableOf(this.defaultUserList);
    } else {
      const request = _.cloneDeep(requestParam);
      const option = {
        url: this.configService.urlConFig.URLS.ADMIN.USER_SEARCH,
        data: {
          request: {
            filters: requestParam.filters || {},
            query: requestParam.query || ''
          }
        }
      };
      if (requestParam.limit) {
        option.data.request['limit'] = requestParam.limit;
      }
      const mentorOrg = this.userService.userProfile.roleOrgMap['COURSE_MENTOR'];
      if (mentorOrg && mentorOrg.includes(this.userService.rootOrgId)) {
        option.data.request.filters['rootOrgId'] = this.userService.rootOrgId;
      } else if (mentorOrg) {
github microsoft / fast-dna / packages / fast-tooling-react / src / form / utilities / plugin.spec.ts View on Github external
public resolver(schema: any, data: any): any {
                if (data.pluginModifiedString === 5) {
                    return undefined;
                }

                return Object.assign({}, schema, { type: "number" });
            }
        }

        const plugins: Array> = [
            new MyUpdateSchemaPlugin({
                id: "plugins/pluginModifiedString",
            }),
        ];

        const beforeDataUpdateSchema: any = cloneDeep(pluginSchema);
        set(beforeDataUpdateSchema, "properties.pluginModifiedString.type", "number");
        set(
            beforeDataUpdateSchema,
            "properties.oneOfs.oneOf[0].properties.pluginModifiedString.type",
            "number"
        );

        const mappedSchema: any = mapPluginsToSchema(pluginSchema, {}, plugins);

        expect(mappedSchema).toEqual(beforeDataUpdateSchema);

        const afterDataUpdateSchema: any = cloneDeep(mappedSchema);
        unset(afterDataUpdateSchema, "properties.pluginModifiedString");
        unset(
            afterDataUpdateSchema,
            "properties.oneOfs.oneOf[0].properties.pluginModifiedString"