Represents a Binder class.

The Binder class is a singleton class that provides functionality for managing and calling functions. It allows you to append new functions, list the existing functions, get a specific function by name, and call a function by name with arguments.

Binder

Implements

Methods

  • Adds a new function to the mappers map with the specified name and function. If a function with the same name already exists, it throws an error.

    Parameters

    Returns void

    If a function with the same name already exists.

    1.0.1

    Binder.append("division", function(a: number, b: number) { return a / b; });

    Binder.append({
    "subtract": function(a: number, b: number) { return a - b; },
    "multiply": (a: number, b: number) => a * b;
    });
  • Calls the function with the specified name from the mappers map with the provided arguments.

    Parameters

    • name: string

      The name of the function.

    • ...args: any[]

      The arguments to be passed to the function.

    Returns any

    The result of calling the function.

    1.0.1

  • Returns the function with the specified name from the mappers map. If the function does not exist, it throws an error.

    Parameters

    • fnName: string

      The name of the function.

    Returns Function

    The function with the specified name.

    If the function with the specified name does not exist.

    1.0.1

  • Returns the instance of the Binder class. If the instance does not exist, it creates a new instance and returns it.

    Returns BinderClass

    The instance of the Binder class.

    1.0.1

  • Returns an array of strings representing the keys in the mappers map.

    Returns string[]

    An array of strings representing the keys in the mappers map.

    1.0.1

  • Updates an existing function in the mappers map with the specified name and function. If the function does not exist, it will be created.

    Parameters

    • fnName: string

      The name of the function to update.

    • func: Function

      The new function to replace the existing one.

    Returns void

    1.0.2

  • Calls a series of functions from the mappers map in a sequential manner, passing the result of each function call as the argument to the next function call.

    Type Parameters

    • D = any

    Parameters

    • mapperNames: string[]

      An array of strings representing the names of the functions to be called.

    • Optionaldata: D

      Optional. The initial data to be passed as the argument to the first function call.

    Returns D

    The final result of calling all the functions in the specified order.

    1.0.1