new Genfun(opts) → {function}
Creates generic functions capable of multiple dispatch across several
arguments. The generic function returned by this constructor is
functionally identical to a standard function: it can be called,
applied, and receives the expected binding for this when appropriate.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
opts |
object |
<optional> |
Options used when initializing the genfun. |
Returns:
New generic function.
- Type
- function
Methods
-
<static> addMethod(genfun, selector, methodFunction)
-
Defines a method on a generic function.
Parameters:
Name Type Description genfunGenfun Genfun instance to add the method to.
selectorArray-like Selector array for dispatching the method.
methodFunctionfunction Function to execute when the method successfully dispatches.
-
<static> noApplicableMethod(genfun, newthis, callArgs)
-
This generic function is called when
genfunhas been called and no applicable method was found. The default method throws anError.Parameters:
Name Type Description genfunGenfun Generic function instance that was called.
newthis* value of
thisthe genfun was called with.callArgsArray Arguments the genfun was called with.
-
<static> removeMethod(genfun, selector)
-
Removes a previously-defined method on
genfunthat matchesselectorexactly.Parameters:
Name Type Description genfunGenfun Genfun to remove a method from.
selectorArray-like Objects to match on when finding a method to remove.