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


TypeScript fp.get函數代碼示例

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


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

示例1: has

const getHostFieldValue = (fieldName: string, bucket: HostAggEsItem): string | string[] | null => {
  const aggField = hostFieldsMap[fieldName]
    ? hostFieldsMap[fieldName].replace(/\./g, '_')
    : fieldName.replace(/\./g, '_');
  if (
    [
      'host.ip',
      'host.mac',
      'cloud.instance.id',
      'cloud.machine.type',
      'cloud.provider',
      'cloud.region',
    ].includes(fieldName) &&
    has(aggField, bucket)
  ) {
    const data: HostBuckets = get(aggField, bucket);
    return data.buckets.map(obj => obj.key);
  } else if (has(`${aggField}.buckets`, bucket)) {
    return getFirstItem(get(`${aggField}`, bucket));
  } else if (has(aggField, bucket)) {
    const valueObj: HostValue = get(aggField, bucket);
    return valueObj.value_as_string;
  }
  return null;
};
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例2: get

export const mergeFieldsWithHit = <T>(
  fieldName: string,
  flattenedFields: T,
  fieldMap: Readonly<Record<string, string>>,
  hit: { _source: {} }
) => {
  if (fieldMap[fieldName] != null) {
    const esField = fieldMap[fieldName];
    if (has(esField, hit._source)) {
      const objectWithProperty = {
        node: {
          ...get('node', flattenedFields),
          ...fieldName
            .split('.')
            .reduceRight((obj, next) => ({ [next]: obj }), get(esField, hit._source)),
        },
      };
      return merge(flattenedFields, objectWithProperty);
    } else {
      return flattenedFields;
    }
  } else {
    return flattenedFields;
  }
};
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例3: updateLoading

 result => {
   updateLoading(false);
   updateFirstSeen(get('data.source.HostFirstLastSeen.firstSeen', result));
   updateLastSeen(get('data.source.HostFirstLastSeen.lastSeen', result));
   updateErrorMessage(null);
   return result;
 },
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例4:

 .case(setDuration, (state, { id, duration }) => ({
   ...state,
   [id]: {
     ...get(id, state),
     policy: {
       ...get(`${id}.policy`, state),
       duration,
     },
   },
 }))
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例5: getHostFirstLastSeen

 public async getHostFirstLastSeen(
   request: FrameworkRequest,
   options: HostLastFirstSeenRequestOptions
 ): Promise<FirstLastSeenHost> {
   const response = await this.framework.callWithRequest<HostAggEsData, TermAggregation>(
     request,
     'search',
     buildLastFirstSeenHostQuery(options)
   );
   const aggregations: HostAggEsItem = get('aggregations', response) || {};
   return {
     firstSeen: get('firstSeen.value_as_string', aggregations),
     lastSeen: get('lastSeen.value_as_string', aggregations),
   };
 }
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例6: filter

 filter(([checkAction, updatedTimeline]) => {
   if (
     checkAction.type === endTimelineSaving.type &&
     updatedTimeline[get('payload.id', checkAction)].savedObjectId != null
   ) {
     myEpicTimelineId.setTimelineId(
       updatedTimeline[get('payload.id', checkAction)].savedObjectId
     );
     myEpicTimelineId.setTimelineVersion(
       updatedTimeline[get('payload.id', checkAction)].version
     );
     return true;
   }
   return false;
 })
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例7: getDomainsFirstLastSeen

  public async getDomainsFirstLastSeen(
    request: FrameworkRequest,
    options: DomainFirstLastSeenRequestOptions
  ): Promise<FirstLastSeenDomain> {
    const response = await this.framework.callWithRequest<SearchHit, TermAggregation>(
      request,
      'search',
      buildFirstLastSeenDomainQuery(options)
    );

    const aggregations: DomainFirstLastSeenItem = get('aggregations', response) || {};
    return {
      firstSeen: get('firstSeen.value_as_string', aggregations),
      lastSeen: get('lastSeen.value_as_string', aggregations),
    };
  }
開發者ID:,項目名稱:,代碼行數:16,代碼來源:


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