当前位置: 首页>>代码示例>>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;未经允许,请勿转载。