@nevware21/ts-utils
    Preparing search index...

    Function fnBindArgs

    • Creates a new bound function using fn.bind() where the pre-bound arguments are supplied as an array or tuple value, similar to how fnApply supplies arguments to invocation.

      This is useful when the argument list is already available as an array or tuple value, but you want to return a reusable bound function rather than invoke immediately.

      Type Parameters

      • F extends (...args: any[]) => any
      • T
      • TArgs extends any[]

      Parameters

      • fn: F

        The function instance to bind.

      • thisArg: T

        The value to be used as the this when calling fn.

      • argArray: TArgs

        Optional array or tuple value containing arguments to pre-bind to fn.

      Returns BoundFunction<F, TArgs>

      A new bound function.

      0.15.0

      const module1 = {
      prefix: "Hello",
      log(value: string, punctuation: string) {
      return this.prefix + " " + value + punctuation;
      }
      };

      const module2 = {
      prefix: "Hi"
      };

      const bound = fnBindArgs(module1.log, module2, ["friend"]);
      bound("!"); // "Hi friend!"
    • Creates a new bound function using fn.bind() where the pre-bound arguments are supplied as an array or tuple value, similar to how fnApply supplies arguments to invocation.

      This is useful when the argument list is already available as an array or tuple value, but you want to return a reusable bound function rather than invoke immediately.

      Type Parameters

      • F extends (...args: any[]) => any
      • T

      Parameters

      • fn: F

        The function instance to bind.

      • thisArg: T

        The value to be used as the this when calling fn.

      Returns F

      A new bound function.

      0.15.0

      const module1 = {
      prefix: "Hello",
      log(value: string, punctuation: string) {
      return this.prefix + " " + value + punctuation;
      }
      };

      const module2 = {
      prefix: "Hi"
      };

      const bound = fnBindArgs(module1.log, module2, ["friend"]);
      bound("!"); // "Hi friend!"