本文整理汇总了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);
}
}
示例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))));
}
}
示例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)));
}
示例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."
//.........这里部分代码省略.........
示例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));
}
示例6: reconstituteProperties
function reconstituteProperties(): ReadonlyMap<string, ClassProperty> {
return mapMap(properties, cp =>
builder.makeClassProperty(builder.reconstituteTypeRef(cp.typeRef), cp.isOptional)
);
}
示例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));
}
示例8: makeAccessorNames
export function makeAccessorNames(x: any): AccessorNames {
// FIXME: Do proper error reporting
const stringMap = checkStringMap(x, isAccessorEntry);
return mapMap(mapFromObject(stringMap), makeAccessorEntry);
}