UNPKG

@typespec/http-server-js

Version:

TypeSpec HTTP server code generator for JavaScript

36 lines 993 B
// Copyright (c) Microsoft Corporation // Licensed under the MIT license. /** * Provides an alternative name for anonymous TypeSpec.Array elements. * @param typeName * @returns */ export function getArrayElementName(typeName) { return typeName + "Element"; } /** * Provides an alternative name for anonymous TypeSpec.Record values. * @param typeName * @returns */ export function getRecordValueName(typeName) { return typeName + "Value"; } /** * Produces the name of an array type for a given base type. * * If the type name is a simple identifier, this will use the `[]` syntax, * otherwise it will use the `Array<>` type constructor. * * @param typeName - the base type to make an array of * @returns a good representation of an array of the base type */ export function asArrayType(typeName) { if (/^[a-zA-Z_]+$/.test(typeName)) { return typeName + "[]"; } else { return `Array<${typeName}>`; } } //# sourceMappingURL=pluralism.js.map