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

TypeScript collection-utils.mapMap函数代码示例

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

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



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

示例1: definedMap

    reconstitute<T extends BaseGraphRewriteBuilder>(builder: TypeReconstituter<T>, canonicalOrder: boolean): void {
        const sortedProperties = this.getSortedProperties();
        const propertiesInNewOrder = canonicalOrder ? sortedProperties : this.getProperties();
        const maybePropertyTypes = builder.lookupMap(mapMap(sortedProperties, cp => cp.typeRef));
        const maybeAdditionalProperties = definedMap(this._additionalPropertiesRef, r => builder.lookup(r));

        if (
            maybePropertyTypes !== undefined &&
            (maybeAdditionalProperties !== undefined || this._additionalPropertiesRef === undefined)
        ) {
            const properties = mapMap(propertiesInNewOrder, (cp, n) =>
                builder.makeClassProperty(defined(maybePropertyTypes.get(n)), cp.isOptional)
            );

            switch (this.kind) {
                case "object":
                    assert(this.isFixed);
                    builder.getObjectType(properties, maybeAdditionalProperties);
                    break;
                case "map":
                    builder.getMapType(defined(maybeAdditionalProperties));
                    break;
                case "class":
                    if (this.isFixed) {
                        builder.getUniqueClassType(true, properties);
                    } else {
                        builder.getClassType(properties);
                    }
                    break;
                default:
                    return panic(`Invalid object type kind ${this.kind}`);
            }
        } else {
            switch (this.kind) {
                case "object":
                    assert(this.isFixed);
                    builder.getUniqueObjectType(undefined, undefined);
                    break;
                case "map":
                    builder.getUniqueMapType();
                    break;
                case "class":
                    builder.getUniqueClassType(this.isFixed, undefined);
                    break;
                default:
                    return panic(`Invalid object type kind ${this.kind}`);
            }

            const reconstitutedTypes = mapMap(sortedProperties, cp => builder.reconstitute(cp.typeRef));
            const properties = mapMap(propertiesInNewOrder, (cp, n) =>
                builder.makeClassProperty(defined(reconstitutedTypes.get(n)), cp.isOptional)
            );
            const additionalProperties = definedMap(this._additionalPropertiesRef, r => builder.reconstitute(r));
            builder.setObjectProperties(properties, additionalProperties);
        }
    }
开发者ID:nrkn,项目名称:quicktype,代码行数:56,代码来源:Type.ts


示例2: mapMap

 protected reconstituteSetOperation<T extends BaseGraphRewriteBuilder>(
     builder: TypeReconstituter<T>,
     canonicalOrder: boolean,
     getType: (members: ReadonlySet<TypeRef> | undefined) => void
 ): void {
     const sortedMemberRefs = mapMap(this.sortedMembers.entries(), t => t.typeRef);
     const membersInOrder = canonicalOrder ? this.sortedMembers : this.members;
     const maybeMembers = builder.lookupMap(sortedMemberRefs);
     if (maybeMembers === undefined) {
         getType(undefined);
         const reconstituted = builder.reconstituteMap(sortedMemberRefs);
         builder.setSetOperationMembers(setMap(membersInOrder, t => defined(reconstituted.get(t))));
     } else {
         getType(setMap(membersInOrder, t => defined(maybeMembers.get(t))));
     }
 }
开发者ID:nrkn,项目名称:quicktype,代码行数:16,代码来源:Type.ts


示例3: renderGraphAndSerialize

 renderGraphAndSerialize(
     typeGraph: TypeGraph,
     givenOutputFilename: string,
     alphabetizeProperties: boolean,
     leadingComments: string[] | undefined,
     rendererOptions: { [name: string]: any },
     indentation?: string
 ): MultiFileRenderResult {
     if (indentation === undefined) {
         indentation = this.defaultIndentation;
     }
     const renderContext = { typeGraph, leadingComments };
     const renderer = this.makeRenderer(renderContext, rendererOptions);
     if ((renderer as any).setAlphabetizeProperties !== undefined) {
         (renderer as ConvenienceRenderer).setAlphabetizeProperties(alphabetizeProperties);
     }
     const renderResult = renderer.render(givenOutputFilename);
     return mapMap(renderResult.sources, s => serializeRenderResult(s, renderResult.names, defined(indentation)));
 }
开发者ID:nrkn,项目名称:quicktype,代码行数:19,代码来源:TargetLanguage.ts


示例4: makeOptionDefinitions

function makeOptionDefinitions(targetLanguages: TargetLanguage[]): OptionDefinition[] {
    const beforeLang: OptionDefinition[] = [
        {
            name: "out",
            alias: "o",
            type: String,
            typeLabel: `FILE`,
            description: "The output file. Determines --lang and --top-level."
        },
        {
            name: "top-level",
            alias: "t",
            type: String,
            typeLabel: "NAME",
            description: "The name for the top level type."
        }
    ];
    const lang: OptionDefinition[] =
        targetLanguages.length < 2
            ? []
            : [
                  {
                      name: "lang",
                      alias: "l",
                      type: String,
                      typeLabel: makeLangTypeLabel(targetLanguages),
                      description: "The target language."
                  }
              ];
    const afterLang: OptionDefinition[] = [
        {
            name: "src-lang",
            alias: "s",
            type: String,
            defaultValue: undefined,
            typeLabel: "json|schema|graphql|postman|typescript",
            description: "The source language (default is json)."
        },
        {
            name: "src",
            type: String,
            multiple: true,
            defaultOption: true,
            typeLabel: "FILE|URL|DIRECTORY",
            description: "The file, url, or data directory to type."
        },
        {
            name: "src-urls",
            type: String,
            typeLabel: "FILE",
            description: "Tracery grammar describing URLs to crawl."
        }
    ];
    const inference: OptionDefinition[] = Array.from(
        mapMap(mapFromObject(inferenceFlags), (flag, name) => {
            return {
                name: dashedFromCamelCase(negatedInferenceFlagName(name)),
                type: Boolean,
                description: flag.negationDescription + "."
            };
        }).values()
    );
    const afterInference: OptionDefinition[] = [
        {
            name: "graphql-schema",
            type: String,
            typeLabel: "FILE",
            description: "GraphQL introspection file."
        },
        {
            name: "graphql-introspect",
            type: String,
            typeLabel: "URL",
            description: "Introspect GraphQL schema from a server."
        },
        {
            name: "http-method",
            type: String,
            typeLabel: "METHOD",
            description: "HTTP method to use for the GraphQL introspection query."
        },
        {
            name: "http-header",
            type: String,
            multiple: true,
            typeLabel: "HEADER",
            description: "HTTP header for the GraphQL introspection query."
        },
        {
            name: "additional-schema",
            alias: "S",
            type: String,
            multiple: true,
            typeLabel: "FILE",
            description: "Register the $id's of additional JSON Schema files."
        },
        {
            name: "no-render",
            type: Boolean,
            description: "Don't render output."
//.........这里部分代码省略.........
开发者ID:nrkn,项目名称:quicktype,代码行数:101,代码来源:index.ts


示例5: enumCaseValues

export function enumCaseValues(e: EnumType, language: string): Map<string, [string, boolean] | undefined> {
    const enumValues = enumValuesTypeAttributeKind.tryGetInAttributes(e.getAttributes());
    if (enumValues === undefined) return mapMap(e.cases.entries(), _ => undefined);
    return mapMap(e.cases.entries(), c => lookupKey(enumValues, c, language));
}
开发者ID:nrkn,项目名称:quicktype,代码行数:5,代码来源:EnumValues.ts


示例6: reconstituteProperties

 function reconstituteProperties(): ReadonlyMap<string, ClassProperty> {
     return mapMap(properties, cp =>
         builder.makeClassProperty(builder.reconstituteTypeRef(cp.typeRef), cp.isOptional)
     );
 }
开发者ID:nrkn,项目名称:quicktype,代码行数:5,代码来源:ReplaceObjectType.ts


示例7: objectPropertyNames

export function objectPropertyNames(o: ObjectType, language: string): Map<string, [string, boolean] | undefined> {
    const accessors = accessorNamesTypeAttributeKind.tryGetInAttributes(o.getAttributes());
    const map = o.getProperties();
    if (accessors === undefined) return mapMap(map, _ => undefined);
    return mapMap(map, (_cp, n) => lookupKey(accessors, n, language));
}
开发者ID:nrkn,项目名称:quicktype,代码行数:6,代码来源:AccessorNames.ts


示例8: makeAccessorNames

export function makeAccessorNames(x: any): AccessorNames {
    // FIXME: Do proper error reporting
    const stringMap = checkStringMap(x, isAccessorEntry);
    return mapMap(mapFromObject(stringMap), makeAccessorEntry);
}
开发者ID:nrkn,项目名称:quicktype,代码行数:5,代码来源:AccessorNames.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript collection-utils.setFilter函数代码示例发布时间:2022-05-24
下一篇:
TypeScript collection-utils.mapFromObject函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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