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


TypeScript fp.isEmpty函數代碼示例

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


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

示例1: isEmpty

 ? schemaFields.fields.reduce((accumulator: OutputSchema, item: Partial<SchemaFields>) => {
     if (item.name) {
       const attr = isEmpty(path) ? item.name : `${path}.${item.name}`;
       if (!isEmpty(item.fields) && isEmpty(path)) {
         return {
           ...accumulator,
           [attr]: {
             ...onlyStringOrNumber(pick(paramsToPick, item)),
             fields: {
               ...convertFieldsToAssociativeArray(item, attr),
             },
           },
         };
       } else if (!isEmpty(item.fields) && !isEmpty(path)) {
         return {
           ...accumulator,
           [attr]: onlyStringOrNumber(pick(paramsToPick, item)),
           ...convertFieldsToAssociativeArray(item, attr),
         };
       } else {
         return {
           ...accumulator,
           [attr]: onlyStringOrNumber(pick(paramsToPick, item)),
         };
       }
     }
     return accumulator;
   }, {})
開發者ID:,項目名稱:,代碼行數:28,代碼來源:

示例2: getFields

export const getFields = (
  data: SelectionSetNode | FieldNode,
  fields: string[] = [],
  postFields: string[] = []
): string[] => {
  if (data.kind === 'Field' && data.selectionSet && !isEmpty(data.selectionSet.selections)) {
    return getFields(data.selectionSet, fields);
  } else if (data.kind === 'SelectionSet') {
    return data.selections.reduce(
      (res: string[], item: SelectionNode) => {
        if (item.kind === 'Field') {
          const field: FieldNode = item as FieldNode;
          if (field.name.kind === 'Name' && field.name.value.includes('kpi')) {
            return [...res, field.name.value];
          } else if (field.selectionSet && !isEmpty(field.selectionSet.selections)) {
            return getFields(field.selectionSet, res, postFields.concat(field.name.value));
          }
          return [...res, [...postFields, field.name.value].join('.')];
        }
        return res;
      },
      fields as string[]
    );
  }

  return fields;
};
開發者ID:,項目名稱:,代碼行數:27,代碼來源:

示例3: removeTags

const prepareDescription = (snippet: Partial<ISnippet>, raw = false) => {
  if (!isEmpty(snippet.description)) {
    return raw ? snippet.description : removeTags(snippet.description);
  }

  return DEFAULT_SNIPPET_DESCRIPTION;
};
開發者ID:Gisto,項目名稱:Gisto,代碼行數:7,代碼來源:prepareSnippet.ts

示例4:

const prepareTags = (snippet: Partial<ISnippet>) => {
  if (!isEmpty(snippet.description)) {
    return snippet.description && snippet.description.match(TAG_REGEX);
  }

  return [];
};
開發者ID:Gisto,項目名稱:Gisto,代碼行數:7,代碼來源:prepareSnippet.ts

示例5: get

const getSchemaFromData = (
  properties: MappingProperties,
  data: DetailItem[],
  index: string,
  path?: string
): DetailItem[] =>
  !isEmpty(properties)
    ? Object.keys(properties).reduce<DetailItem[]>((accumulator, property) => {
        const item = get(property, properties);
        const field = path ? `${path}.${property}` : property;
        const dataFilterItem = data.filter(dataItem => dataItem.field === field);
        if (item.properties == null && dataFilterItem.length === 1) {
          const dataItem = dataFilterItem[0];
          const dataFromMapping = {
            type: get([property, 'type'], properties),
          };
          return [
            ...accumulator,
            {
              ...dataItem,
              ...(hasDocumentation(index, field)
                ? merge(getDocumentation(index, field), dataFromMapping)
                : dataFromMapping),
            },
          ];
        } else if (item.properties != null) {
          return [...accumulator, ...getSchemaFromData(item.properties, data, index, field)];
        }
        return accumulator;
      }, [])
    : data;
開發者ID:,項目名稱:,代碼行數:31,代碼來源:

示例6:

 schema.reduce((accumulator: OutputSchema, item: Partial<SchemaItem>) => {
   if (item.fields != null && !isEmpty(item.fields)) {
     return {
       ...accumulator,
       ...convertFieldsToAssociativeArray(item),
     };
   }
   return accumulator;
 }, {});
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例7: orderBy

export const filterSnippetsList = (
  snippets: ISnippet,
  filterText: string,
  filterTags: string,
  filterLanguage: string,
  filterStatus: string,
  filterTruncated: string,
  filterUntagged: string
) => {
  // @ts-ignore
  const sortedSnippets: ISnippet = orderBy(
    [getSetting('settings-snippet-order-field', 'created')],
    [getSetting('settings-snippet-order-direction', 'desc')],
    snippets
  );

  if (!isEmpty(trim(filterText))) {
    return filterByFreeText(sortedSnippets, trim(filterText));
  }

  if (!isEmpty(filterTags)) {
    return filterByTags(sortedSnippets, filterTags);
  }

  if (!isEmpty(trim(filterLanguage))) {
    return filterByLanguage(sortedSnippets, trim(filterLanguage));
  }

  if (!isEmpty(trim(filterStatus))) {
    return filterByStatus(sortedSnippets, trim(filterStatus));
  }

  if (filterTruncated) {
    // @ts-ignore
    return filter({ truncated: true }, sortedSnippets);
  }

  if (filterUntagged) {
    return filter((snippet) => snippet.tags === null || size(snippet.tags) === 0, sortedSnippets);
  }

  return sortedSnippets;
};
開發者ID:Gisto,項目名稱:Gisto,代碼行數:43,代碼來源:snippets.ts

示例8: if

 (res: string[], item: SelectionNode) => {
   if (item.kind === 'Field') {
     const field: FieldNode = item as FieldNode;
     if (field.name.kind === 'Name' && field.name.value.includes('kpi')) {
       return [...res, field.name.value];
     } else if (field.selectionSet && !isEmpty(field.selectionSet.selections)) {
       return getFields(field.selectionSet, res, postFields.concat(field.name.value));
     }
     return [...res, [...postFields, field.name.value].join('.')];
   }
   return res;
 },
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例9: Error

export const parseFilterQuery = (filterQuery: string): JsonObject => {
  try {
    if (filterQuery && isString(filterQuery) && !isEmpty(filterQuery)) {
      const parsedFilterQuery = JSON.parse(filterQuery);
      if (
        !parsedFilterQuery ||
        !isPlainObject(parsedFilterQuery) ||
        Array.isArray(parsedFilterQuery)
      ) {
        throw new Error('expected value to be an object');
      }
      return parsedFilterQuery;
    }
    return {};
  } catch (err) {
    throw new UserInputError(`Failed to parse query: ${err}`, {
      query: filterQuery,
      originalError: err,
    });
  }
};
開發者ID:,項目名稱:,代碼行數:21,代碼來源:


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