Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "src/loader"

Index

Type aliases

ConstructorCallback

ConstructorCallback: function

Constructor callback.

param

Fullfills when constructor finishes execution

Type declaration

    • (done: Promise<void>): void
    • Parameters

      • done: Promise<void>

      Returns void

Functions

initRecursion

  • initRecursion(rootDir: string, relativePath: string, initFilename: string, targetObject: any, extend: boolean): Promise<void>
  • System loader recursion.

    Note

    • Default values are assumed for unspecified or empty values.
    • Extension means recursive loading of data into variable, as if loading a new file into the current variable as new system.
    • Relative path is relative to the directory location of current file.

      Default filename - null

    # Variable settings to be populated with data from "system_root_dir/settings.yml"
    settings: # Defaults to "settings"

    Default filename - empty string

    # Variable settings to be populated with data from "system_root_dir/settings.yml"
    settings: "" # Defaults to "settings"

    Specified filename

    # Variable settings to be populated with data from "system_root_dir/xxx.yml"
    settings: "xxx"

    Default values

    # Variable settings to be populated with data from "system_root_dir/settings.yml"
    settings:
      folder: # Defaults to "./"
      file: # Defaults to "settings"
      path: # Defaults to "absolute"
      extend: # Defaults to "false"

    Specified values

    # Variable settings to be populated with data from "current_dir/hello/xxx.yml"
    settings:
      folder: "hello"
      file: xxx
      path: relative
      extend: false

    Extension

    # Variable settings to be populated **recursively** with data from "current_dir/hello/xxx.yml"
    settings:
      folder: "hello"
      file: xxx
      path: relative
      extend: true

    Usage

    // Input - ./settings/init.yml
    // settings:
    //   path: relative
    
    // Input - ./settings/settings.yml
    // apples: red
    // bananas: yellow
    
    // Target object to fill
    var targetObject = {};
    
    initRecursion("./", "settings", "init.yml", targetObject, true));
    throws

    Error Will throw an error if the directive is not an allowed one (folder, file, path, extend).

    Parameters

    • rootDir: string

      Root directory.

    • relativePath: string

      Relative path.

    • initFilename: string

      Filename for settings.

    • targetObject: any

      Object to be filled.

    • extend: boolean

      Extend the children objects or not.

    Returns Promise<void>

initSettings

  • initSettings(rootDir: string, relativeDir: string, filename: string): Promise<any>
  • Init and populate globalspace with settings - specific global object member per file. Semantically this function has broader purpose than loadYaml.

    Usage

    var settings = await initSettings("./", "settings", "settings");

    Parameters

    • rootDir: string

      Root directory.

    • relativeDir: string
    • filename: string

      Filename.

    Returns Promise<any>

    Javascript object with settings.

loadYaml

  • loadYaml(rootDir: string, relativeDir: string, filename: string): Promise<any>
  • Parses YAML file, and returns and object; Adds extension if absent.

    Usage

    var settings = await loadYaml("./", "settings", "settings");

    Parameters

    • rootDir: string

      Absolute directory path.

    • relativeDir: string

      Relative directory to root.

    • filename: string

      Filename, with or without extension.

    Returns Promise<any>

    Javascript object.

Generated using TypeDoc