mwbot-ts - v1.2.7
    Preparing search index...

    Interface ParsedParserFunction

    The instance members of the ParsedParserFunction class. For static members, see ParsedParserFunctionStatic (defined separately due to TypeScript limitations).

    interface ParsedParserFunction {
        canonicalHook: string;
        children: Set<number>;
        endIndex: number;
        hook: string;
        index: number;
        nestLevel: number;
        params: string[];
        parent: null | number;
        rawHook: string;
        skip: boolean;
        startIndex: number;
        text: string;
        addParam(param: string): this;
        deleteParam(index: number, leftShift?: boolean): boolean;
        getParam(index: number): null | string;
        hasParam(index: number, value?: string | RegExp): boolean;
        hasParam(predicate: (index: number, value: string) => boolean): boolean;
        setHook(hook: string): boolean;
        setParam(
            param: string,
            index: number,
            options?: { ifexist?: boolean; overwrite?: boolean },
        ): boolean;
        stringify(options?: ParsedParserFunctionOutputConfig): string;
        toString(): string;
        toTemplate(title: string | Title, verbose?: boolean): null | ParsedTemplate;
    }

    Hierarchy (View Summary)

    Index

    Properties

    canonicalHook: string

    The canonical parser function hook.

    This property is automatically set and updated on a successful call of setHook.

    children: Set<number>

    The indices of the child objects within the parseTemplates result array.

    endIndex: number

    The ending index of this double-braced markup in the wikitext (exclusive).

    hook: string

    The parser function hook. This may be an alias of the canonical hook.

    This property is read-only. To update it, use setHook.

    index: number

    The index of this object within the result array returned by parseTemplates.

    nestLevel: number

    The nesting level of this double-braced markup. 0 if not nested within another double-braced expression.

    params: string[]

    Parameters of the instance. These are not automatically trimmed of leading and trailing whitespace.

    parent: null | number

    The index of the parent object within the parseTemplates result array, or null if there is no parent.

    rawHook: string

    The raw parser function hook, as directly parsed from the wikitext.

    skip: boolean

    Whether the double-braced markup appears inside an HTML tag specified in SkipTags.

    startIndex: number

    The starting index of this double-braced markup in the wikitext.

    text: string

    The original text of the double-braced markup parsed from the wikitext. The value of this property is static.

    Methods

    • Deletes a parameter.

      Parameters

      • index: number

        The parameter index to delete.

      • leftShift: boolean = true

        Whether to shift the remaining parameters to the left after deletion. (Default: true)

      Returns boolean

      true if the parameter was deleted, otherwise false.

    • Gets a parameter at the given index.

      Parameters

      • index: number

        The index of the parameter to retrieve.

      Returns null | string

      The parameter value, or null if no value is found at the specified index.

    • Checks if a parameter at the specified index exists, optionally matching its value.

      Parameters

      • index: number

        The parameter index to match.

      • Optionalvalue: string | RegExp

        The optional value matcher.

        • If a string, checks for an exact value match.
        • If a regular expression, tests the parameter value against the pattern.
        • If omitted, only the parameter index is checked.

      Returns boolean

      true if a matching parameter exists; otherwise, false.

    • Checks if a parameter exists based on a custom predicate function.

      Parameters

      • predicate: (index: number, value: string) => boolean

        A function that tests each parameter.

      Returns boolean

      true if a matching parameter exists; otherwise, false.

    • Sets a new function hook, overwriting the current one.

      Parameters

      • hook: string

        The new hook.

      Returns boolean

      A boolean indicating whether the new hook was set.

    • Sets a parameter at the given index.

      Parameters

      • param: string

        The new parameter.

      • index: number

        The index of the parameter to update.

      • options: { ifexist?: boolean; overwrite?: boolean } = {}

        Options to set the new parameter.

        • Optionalifexist?: boolean

          Whether to set the parameter only if a parameter is already set at the specified index.

        • Optionaloverwrite?: boolean

          Whether to overwrite existing parameters. If false, the new parameter is not registered if there is an existing parameter at the specified index. (Default: true)

      Returns boolean

      A boolean indicating whether the new parameter has been set.

    • Converts the instance to a ParsedTemplate.

      The conversion is based on the data used to initialize this instance, and any modifications made after initialization will be discarded. Therefore, this method should be called before making any changes to the instance properties.

      Parameters

      • title: string | Title

        The new template title to set.

      • Optionalverbose: boolean

        Whether to log errors (default: false).

      Returns null | ParsedTemplate

      A new ParsedTemplate instance on success; otherwise, null.