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

TypeScript util.filterAndJoinArray函数代码示例

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

本文整理汇总了TypeScript中@gql2ts/util.filterAndJoinArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript filterAndJoinArray函数的具体用法?TypeScript filterAndJoinArray怎么用?TypeScript filterAndJoinArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了filterAndJoinArray函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: filterAndJoinArray

 const generateRootTypes: (schema: GraphQLSchema) => string = schema => filterAndJoinArray(
   [
     interfaceBuilder(
       generateInterfaceName('GraphQLResponseRoot'),
       gID([
         formatInput('data', !optionsInput.legacy, generateRootDataName(schema)),
         formatInput('errors', !optionsInput.legacy, wrapList(generateInterfaceName('GraphQLResponseError')))
       ])
     ),
     interfaceBuilder(
       generateInterfaceName('GraphQLResponseError'),
       gID([
         '/** Required for all errors */',
         formatInput('message', false, TYPE_MAP.String),
         formatInput('locations', !optionsInput.legacy, wrapList(generateInterfaceName('GraphQLResponseErrorLocation'))),
         `/** 7.2.2 says 'GraphQL servers may provide additional entries to error' */`,
         formatInput('[propName: string]', false, TYPE_MAP.__DEFAULT),
       ])
     ),
     interfaceBuilder(
       generateInterfaceName('GraphQLResponseErrorLocation'),
       gID([
         formatInput('line', false, TYPE_MAP.Int),
         formatInput('column', false, TYPE_MAP.Int),
       ])
     )
   ],
   '\n\n'
 );
开发者ID:avantcredit,项目名称:gql2ts,代码行数:29,代码来源:index.ts


示例2: postProcessor

 const joinOutputs: (output: IOutputJoinInput) => IFromQueryReturnValue = output => {
   const { variables, additionalTypes, interface: iface } = output;
   const result: string = postProcessor(filterAndJoinArray([variables, ...additionalTypes, iface], '\n\n'));
   return {
     ...output,
     result
   };
 };
开发者ID:avantcredit,项目名称:gql2ts,代码行数:8,代码来源:index.ts


示例3: resolveInterfaceName

  const generateArgumentDeclaration: ArgumentToDefinition = (arg, supportsNullability) => {
    const resolved: ResolvedInterfaceValue = resolveInterfaceName(arg.type, false);

    return filterAndJoinArray([
      generateDocumentation(buildDocumentation(arg)),
      formatInput(arg.name, !resolved.isNonNull, typePrinter(resolved, supportsNullability))
    ]);
  };
开发者ID:avantcredit,项目名称:gql2ts,代码行数:8,代码来源:index.ts


示例4: filterAndJoinArray

export const DEFAULT_ENUM_FORMATTER: EnumFormatter = (values, documentationGenerator) => `{
  ${filterAndJoinArray(
    values.map(value => filterAndJoinArray([
      documentationGenerator(buildDocumentation(value)),
      `${value.name} = '${value.name}'`
    ])),
    ',\n'
  )}
}`;
开发者ID:avantcredit,项目名称:gql2ts,代码行数:9,代码来源:index.ts


示例5: fixDescriptionDocblock

export const DEFAULT_DOCUMENTATION_GENERATOR: GenerateDocumentation = ({ description, tags = [] }) => {
  if (!description && !tags.length) {
    return '';
  }
  const arr: Array<string | undefined> = [
    fixDescriptionDocblock(description),
    ...tags.map(({ tag, value }) => `@${tag} ${JSON.stringify(value)}`)
  ];
  return `
  /**
   * ${filterAndJoinArray(arr, '\n   * ')}
   */`;
};
开发者ID:avantcredit,项目名称:gql2ts,代码行数:13,代码来源:index.ts


示例6: generateAbstractTypeDeclaration

  const typeToInterface: TypeToInterface = (type, ignoredTypes, supportsNullability) => {
    if (isScalar(type)) {
      return null;
    }

    if (isUnion(type)) {
      return generateAbstractTypeDeclaration(type, ignoredTypes);
    }

    if (isEnum(type)) {
      return generateEnumDeclaration(type.description, type.name, type.getValues());
    }

    const isInput: boolean = type instanceof GraphQLInputObjectType;
    const f1: GraphQLInputFieldMap | GraphQLFieldMap<any, any> = type.getFields();
    const f: Array<GraphQLField<any, any> | GraphQLInputField> = Object.keys(f1).map(k => f1[k]);

    const filteredFields: Array<GraphQLField<any, any> | GraphQLInputField> = f.filter(field => filterField(field, ignoredTypes));

    const fields: string[] = filteredFields
      .map(field => [generateDocumentation(buildDocumentation(field)), fieldToDefinition(field, isInput, supportsNullability)])
      .reduce((acc, val) => [...acc, ...val], [])
      .filter(Boolean);

    const interfaceDeclaration: string = generateInterfaceName(type.name);
    let additionalInfo: string = '';

    if (isAbstractType(type)) {
      additionalInfo = generateAbstractTypeDeclaration(type, ignoredTypes);
    }

    return filterAndJoinArray(
      [
        generateInterfaceDeclaration(type, interfaceDeclaration, fields, additionalInfo, isInput),
        ...filteredFields.map(field => generateArgumentsDeclaration(field, type.name, supportsNullability))
      ],
      '\n\n'
    );
  };
开发者ID:avantcredit,项目名称:gql2ts,代码行数:39,代码来源:index.ts


示例7: Set

  const typesToInterfaces: (schema: GraphQLSchema, options: Partial<IInternalOptions>) => string = (schema, options) => {
    const ignoredTypes: Set<string> = new Set(options.ignoredTypes);
    const supportsNullability: boolean = !options.legacy;
    const types: { [typeName: string]: GraphQLNamedType } = schema.getTypeMap();
    const typeArr: GraphQLNamedType[] = Object.keys(types).map(k => types[k]);

    const typeInterfaces: string[] =
      typeArr
        .filter(type => !type.name.startsWith('__'))  // remove introspection types
        .filter(type =>                               // remove ignored types
          !ignoredTypes.has(type.name)
        )
        .map(type =>                                  // convert to interface
          typeToInterface(type, ignoredTypes, supportsNullability)!
        );

    return filterAndJoinArray(
      [
        generateRootTypes(schema),
        ...typeInterfaces
      ],
      '\n\n'
    );
  };
开发者ID:avantcredit,项目名称:gql2ts,代码行数:24,代码来源:index.ts


示例8:

export const interfaceExtendListToString: (extensions: string[]) => string = exts => {
  if (!exts.length) { return ''; }
  return ` extends ${filterAndJoinArray(exts, ', ')}`;
};
开发者ID:avantcredit,项目名称:gql2ts,代码行数:4,代码来源:index.ts



注:本文中的@gql2ts/util.filterAndJoinArray函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript ui.getColorFromHexRgbOrName函数代码示例发布时间:2022-05-28
下一篇:
TypeScript types.GetChildSelectionsType类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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