• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fp.isEmpty函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fp.isFinite函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fp.isArray函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap