Type Alias: poemLengths
poemLengths = readonly ["short"
, "medium"
, "long"
]
Defined in: src/poem/poem-generator.ts:26
Overview
The poemLengths
type alias represents a readonly array of predefined lengths for poems. It specifies the available configurations that can be used when generating or categorizing poems.
Usage
This type alias can be employed in functions or components that require specific lengths to define the format of poems being processed.
Example
The following TypeScript code demonstrates how to use the poemLengths
type in a function that generates poems of defined lengths:
function generatePoem(length: poemLengths): string {
switch (length) {
case "short":
return "This is a short poem.";
case "medium":
return "This poem is longer than a short one, but not too long.";
case "long":
return "This is a long poem, rich with details and depth.";
default:
throw new Error("Invalid poem length specified.");
}
}
Parameters
- length:
poemLengths
- A parameter that accepts one of the predefined values:"short"
,"medium"
, or"long"
.
Returns
string
- This function returns a poem string corresponding to the specified length.
Last updated on