當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash.set函數代碼示例

本文整理匯總了TypeScript中lodash.set函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript set函數的具體用法?TypeScript set怎麽用?TypeScript set使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了set函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: setValue

 public async setValue(opts: CommandOptions) {
   // get value so we have a type
   const splitted = opts.parameters.split(' ');
   const pointer = splitted.shift();
   let newValue = splitted.join(' ');
   if (!pointer) {
     return sendMessage(`$sender, settings does not exists`, opts.sender);
   }
   const currentValue = await get(global, pointer, undefined);
   if (typeof currentValue !== 'undefined') {
     if (isBoolean(currentValue)) {
       newValue = newValue.toLowerCase().trim();
       if (['true', 'false'].includes(newValue)) {
         set(global, pointer, newValue === 'true');
         sendMessage(`$sender, ${pointer} set to ${newValue}`, opts.sender);
       } else {
         sendMessage('$sender, !set error: bool is expected', opts.sender);
       }
     } else if (isNumber(currentValue)) {
       if (isFinite(Number(newValue))) {
         set(global, pointer, Number(newValue));
         sendMessage(`$sender, ${pointer} set to ${newValue}`, opts.sender);
       } else {
         sendMessage('$sender, !set error: number is expected', opts.sender);
       }
     } else if (isString(currentValue)) {
       set(global, pointer, newValue);
       sendMessage(`$sender, ${pointer} set to '${newValue}'`, opts.sender);
     } else {
       sendMessage(`$sender, ${pointer} is not supported settings to change`, opts.sender);
     }
   } else {
     sendMessage(`$sender, ${pointer} settings not exists`, opts.sender);
   }
 }
開發者ID:sogehige,項目名稱:SogeBot,代碼行數:35,代碼來源:general.ts

示例2: set

    groupBy.forEach((grouping: InfraPathInput, index: number) => {
      if (isGroupByTerms(grouping)) {
        const termsAgg = {
          aggs: {},
          terms: {
            field: grouping.field,
            size: 10,
          },
        };
        set(aggs, `path_${index}`, termsAgg);
        aggs = termsAgg.aggs;
      }

      if (grouping && isGroupByFilters(grouping)) {
        const filtersAgg = {
          aggs: {},
          filters: {
            filters: grouping.filters!.map(
              (filter: InfraPathFilterInput): InfraESQueryStringQuery => {
                return {
                  query_string: {
                    analyze_wildcard: true,
                    query: (filter && filter.query) || '*',
                  },
                };
              }
            ),
          },
        };
        set(aggs, `path_${index}`, filtersAgg);
        aggs = filtersAgg.aggs;
      }
    });
開發者ID:gingerwizard,項目名稱:kibana,代碼行數:33,代碼來源:group_by_processor.ts

示例3: return

  return (doc: InfraESSearchBody) => {
    const result = cloneDeep(doc);
    const field = nodeTypeToField(options);

    set(result, 'aggs.waffle.aggs.nodes.terms', {
      field,
      include: {
        num_partitions: options.numberOfPartitions,
        partition: options.partitionId,
      },
      order: { _key: 'asc' },
      size: NODE_REQUEST_PARTITION_SIZE * NODE_REQUEST_PARTITION_FACTOR,
    });

    set(result, 'aggs.waffle.aggs.nodes.aggs', {
      nodeDetails: {
        top_hits: {
          size: 1,
          _source: { includes: [NAME_FIELDS[options.nodeType]] },
          sort: [{ [fields.timestamp]: { order: 'desc' } }],
        },
      },
    });
    return result;
  };
開發者ID:gingerwizard,項目名稱:kibana,代碼行數:25,代碼來源:nodes_processor.ts

示例4: removeArtifactFromField

 public static removeArtifactFromField(field: string, obj: { [key: string]: string | string[] }, artifactId: string) {
   const reference = get(obj, field);
   if (Array.isArray(reference)) {
     set(obj, field, reference.filter((a: string) => a !== artifactId));
   } else if (reference === artifactId) {
     set(obj, field, null);
   }
 }
開發者ID:spinnaker,項目名稱:deck,代碼行數:8,代碼來源:ArtifactReferenceService.ts

示例5: it

 it("returns UTC when browser support is not there", () => {
   const x = get(window, "Intl", undefined);
   set(window, "Intl", undefined);
   window.alert = jest.fn();
   expect(inferTimezone(undefined)).toBe("UTC");
   expect(window.alert).toHaveBeenCalledWith(expect.stringContaining("UTC"));
   set(window, "Intl", x);
 });
開發者ID:RickCarlino,項目名稱:farmbot-web-app,代碼行數:8,代碼來源:guess_timezone_test.ts

示例6: getIndexBoundsForPointData

export function getIndexBoundsForPointData(data: SeriesData, xValueBounds: Interval, xValuePath: string): IndexBounds {
  const lowerBound = _.set({}, xValuePath, xValueBounds.min);
  const upperBound = _.set({}, xValuePath, xValueBounds.max);

  const firstIndex = _.sortedIndexBy(data, lowerBound, xValuePath);
  const lastIndex = _.sortedLastIndexBy(data, upperBound, xValuePath);

  return adjustBounds(firstIndex, lastIndex, data.length);
}
開發者ID:abe732,項目名稱:react-layered-chart,代碼行數:9,代碼來源:renderUtils.ts

示例7: it

  it("Does not crash if process.env.NODE_ENV is undefined", () => {
    const old = get(process.env, "NODE_ENV", "development");
    set(process.env, "NODE_ENV", "");
    const result1 = configureStore();

    expect(result1)
      .toEqual(expect.objectContaining({ getState: expect.anything() }));
    set(process.env, "NODE_ENV", old);
  });
開發者ID:FarmBot,項目名稱:Farmbot-Web-API,代碼行數:9,代碼來源:store_tests.ts

示例8: getBoundsForInstantaeousData

export function getBoundsForInstantaeousData(timestampedData: SeriesData, timeRange: Range, timestampPath: string = 'timestamp'): IndexBounds {
  const lowerBound = _.set({}, timestampPath, timeRange.min);
  const upperBound = _.set({}, timestampPath, timeRange.max);

  const firstIndex = _.sortedIndexBy(timestampedData, lowerBound, timestampPath);
  const lastIndex = _.sortedLastIndexBy(timestampedData, upperBound, timestampPath);

  return adjustBounds(firstIndex, lastIndex, timestampedData.length);
}
開發者ID:briann,項目名稱:react-layered-chart,代碼行數:9,代碼來源:util.ts

示例9:

 await Promise.all(tmpl2paths(template).map(async path => {
     const val = await _.get(params, path);
     if (val) {
         if (typeof val === "object") {
             const val_ = await val.toString();
             _.set(params_, path + ".toString", () => val_);
         } else {
             _.set(params_, path, val);
         }
     }
 }));
開發者ID:prigaux,項目名稱:compte-externe,代碼行數:11,代碼來源:mail.ts


注:本文中的lodash.set函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。