Options
All
  • Public
  • Public/Protected
  • All
Menu

Module compiler/src/main

Index

Type aliases

ContainerNode

MfmlParser

MfmlParser: (input: string) => Node

Type declaration

    • (input: string): Node
    • Parameters

      • input: string

      Returns Node

Node

Functions

compileEmptyFragment

compileFunction

compileFunctionBody

compileLocaleNodeMap

compileMessage

compileModule

compileNode

countNodes

  • countNodes(nodes: Node[]): 0 | 1 | 2

createAtRuntimeCompiler

  • Creates a compiler that produces message functions.

    import {createAtRuntimeCompiler} from '@mfml/compiler/lib/at-runtime';
    import {stringRuntime} from '@mfml/runtime';
    
    const compile = createAtRuntimeCompiler();
    
    const message = compile({
      en: 'Bye, {name}!',
      ru: 'Пока, {name}!',
      es: 'Adiós, {name}!',
    });
    
    message(stringRuntime, 'en', {name: 'Karen'}); // → 'Bye, Karen!'
    

    Type parameters

    • Values: void | object

    Parameters

    Returns (translations: Record<string, string>) => MessageFunction<Values>

      • Creates a compiler that produces message functions.

        import {createAtRuntimeCompiler} from '@mfml/compiler/lib/at-runtime';
        import {stringRuntime} from '@mfml/runtime';
        
        const compile = createAtRuntimeCompiler();
        
        const message = compile({
          en: 'Bye, {name}!',
          ru: 'Пока, {name}!',
          es: 'Adiós, {name}!',
        });
        
        message(stringRuntime, 'en', {name: 'Karen'}); // → 'Bye, Karen!'
        

        Parameters

        • translations: Record<string, string>

        Returns MessageFunction<Values>

createMfmlParser

isBlankNode

  • isBlankNode(node: Node | null | undefined): boolean

isContainerNode

isSelectNode

isTextNode

visitNode

Generated using TypeDoc