UNPKG

@zsnout/ithkuil

Version:

A set of tools which can generate and parse romanized Ithkuil text and which can generate Ithkuil script from text and JSON data.

112 lines (111 loc) 4.69 kB
import type { VowelForm } from "../../parse/vowel-form.js"; export type Text = string | WithWYAlternative; export type Joinable = Text | VowelForm | null | undefined; /** * Represents strings that have alternatives when preceded by W or Y, such as * most of the vowel forms in column 3 of the standard vowel table. */ export declare class WithWYAlternative { readonly defaultValue: string; readonly valueAfterW: string; readonly valueAfterY: string; /** * Adds two strings or `WithWYAlternative`s. * * @param first The left side of the output. * @param second The right side of the output. * @returns A string containing the output. */ static add(first: string, second: Text): string; /** * Adds two strings or `WithWYAlternative`s. * * @param first The left side of the output. * @param second The right side of the output. * @returns A `WithWYAlternative` containing the output. */ static add(first: WithWYAlternative, second: Text): WithWYAlternative; /** * Adds two strings or `WithWYAlternative`s. * * @param first The left side of the output. * @param second The right side of the output. * @returns A string or `WithWYAlternative` representing the output. */ static add(first: Text, second: Text): Text; /** * Coerces a string or `WithWYAlternative` as a `WithWYAlternative`. * * @param text The string or `WithWYAlternative` to create an object from. * @returns A `WithWYAlternative` containing the input data. */ static of(text: Text): WithWYAlternative; /** * Constructs a `WithWYAlternative`. * * @param defaultValue The default value. * @param valueAfterW The value when preceded by W. * @param valueAfterY The value when preceded by Y. * @returns The constructed, frozen `WithWYAlternative`. */ constructor(defaultValue: string, valueAfterW: string, valueAfterY: string); /** * Gets the appropriate field (defaultValue, precededByW, or precededByY) * based on the contents of text preceding this `WithWYAlternative`. * * @param text The text preceding this `WithWYAlternative`. * @returns The value of the appropriate field. */ withPreviousText(text: string): string; /** * Adds this `WithWYAlternative` to a string or another `WithWYAlternative`. * * @param other A string or `WithWYAlternative` to add this to. * @returns A `WithWYAlternative` containing the appropriate outputs. */ add(other: Text): WithWYAlternative; /** * Stringifies this WithWYAlternative. * * @returns A stringified representation of this WithWYAlternative. */ toString(): string; /** * Inserts glottal stops into this `WithWYAlternative`. * * @param isAtEndOfWord Whether this `WithWYAlternative` is at the end of a * word. * @returns A `WithWYAlternative` containing the contents of this one, but * with a glottal stop in each alternative. */ insertGlottalStop(isAtEndOfWord: boolean): WithWYAlternative; } /** A `WithWYAlternative` instance containing the empty string. */ export declare const EMPTY: WithWYAlternative; /** A `WithWyAlternative` instance containing `ia/uä`. */ export declare const IA_UÄ: WithWYAlternative; /** A `WithWyAlternative` instance containing `ie/uë`. */ export declare const IE_UË: WithWYAlternative; /** A `WithWyAlternative` instance containing `io/üä`. */ export declare const IO_ÜÄ: WithWYAlternative; /** A `WithWyAlternative` instance containing `iö/üë`. */ export declare const IÖ_ÜË: WithWYAlternative; /** A `WithWyAlternative` instance containing `uö/öë`. */ export declare const UÖ_ÖË: WithWYAlternative; /** A `WithWyAlternative` instance containing `uo/öä`. */ export declare const UO_ÖÄ: WithWYAlternative; /** A `WithWyAlternative` instance containing `ue/ië`. */ export declare const UE_IË: WithWYAlternative; /** A `WithWyAlternative` instance containing `ua/iä`. */ export declare const UA_IÄ: WithWYAlternative; /** * Joins several strings and vowel forms into a `WithWYAlternative`. Passing the * proper `isAtEndOfWord` value to `VowelForm`s is taken care of automatically. * * This is intended to be used to create a full word, as it will not preserve * forms which can alternate if they are at the beginning of the word. * * @param texts The strings and `WithWYAlternative`s to create an object from. * @returns A `WithWYAlternative` containing all input data, joined properly. */ export declare function join(...texts: (Joinable | Joinable[])[]): string;