ish.oop.overload

OOP Dynamic Polymorphism (Function Overloading) mixin for ish.js

Source:
Author:
  • Nick Campbell
License:
  • MIT

Methods

[mixin] ish.oop.overload(fnDefaultopt) → {object|function|function|function}

Source:
Initiates a wrapper function that marshals calls to the proper function overload based on argument signature.
From Mixin: ish.oop.overload.js must be included for ishJS to access this functionality.
Parameters:
Name Type Attributes Description
fnDefault function <optional>
Value representing the default overload function to execute if the arguments cannot be matched to an available overload.
Returns:
Name Type Description
interface object Value representing the following properties:
Properties
Name Type Description
add function Adds another function to the available overloads; add(fn, sAlias, a_vArgumentTests):
fnfunctionValue representing the function to add to the available overloads.
sAliasstringValue representing the unique alias for the passed function.
a_vArgumentTestsfunction[] | string[]Value representing the argument validators as functions or strings referencing ish.types.*.is functions (e.g. str, int, obj, etc).
default function Default function overload to execute if the arguments cannot be matched to an available overload; default().
list function Lists the available overloaded functions; list(iArgumentCount):
iArgumentCountintegerValue representing the desired argument count to limit the returned list to.

[mixin] ish.oop.overload.is(fnTarget) → {boolean}

Source:
Determines if the passed value is a wrapper function that marshals calls to the proper function overload based on argument signature.
From Mixin: ish.oop.overload.js must be included for ishJS to access this functionality.
Parameters:
Name Type Description
fnTarget function Value representing the function to test.
Returns:
Type Description
boolean Value representing if the passed value is a wrapper function that marshals calls to the proper function overload based on argument signature.